Skip to content

JAVA-7405 Read the SemSitter frontend flag from LaunchDarkly - #6582

Open
rombirli wants to merge 2 commits into
rombirli/semsitter-cast-catch-warningsfrom
rombirli/semsitter-feature-flags
Open

rombirli wants to merge 2 commits into
rombirli/semsitter-cast-catch-warningsfrom
rombirli/semsitter-feature-flags

Conversation

@rombirli

@rombirli rombirli commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part 15 of 17 of JAVA-7392. Ticket: JAVA-7405.

Intent

A small LaunchDarkly client to read one boolean flag per project, with no SDK dependency: one HTTPS call to the client-side evaluation endpoint.

sequenceDiagram
  participant A as Analysis
  participant L as LaunchDarklyFeatureFlags
  participant LD as clientsdk.launchdarkly.com
  A->>L: connect(clientSideId, projectKey)
  A->>L: isEnabled(flag, default)
  L->>LD: GET /sdk/evalx/{id}/contexts/{base64 context}
  LD-->>L: {"flag": {"value": true}}
  L-->>A: true, or default on any failure
Loading
FeatureFlags flags = LaunchDarklyFeatureFlags.connect(clientSideId, "my-project");
boolean on = flags.isEnabled("sonar-java-semsitter-frontend", false);   // never throws

State on master

Nothing reads a flag yet.

Test plan

  • LaunchDarklyFeatureFlagsTest against a local HTTP server: on, off, unknown or non-boolean flag, failing or unreachable service, interruption, malformed answer

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

JAVA-7405

@rombirli
rombirli added this pull request to stack #6570 November 25, 2026 11:48
@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch from c240b14 to 92c8e3c Compare November 25, 2026 12:00
@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch 2 times, most recently from 628923b to e540a42 Compare November 25, 2026 13:08
@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch 2 times, most recently from 30beb3b to 973734e Compare November 25, 2026 14:14
@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch from 973734e to cf3b27c Compare November 25, 2026 14:55
@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch from cf3b27c to 62396a7 Compare November 25, 2026 15:32
@sonarqube-next

Copy link
Copy Markdown
Contributor

@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch 2 times, most recently from 6895328 to 72774ba Compare November 25, 2026 17:16
@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch 2 times, most recently from 29968e8 to ea41ce2 Compare November 25, 2026 18:39
@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch from ea41ce2 to ee828cc Compare November 25, 2026 20:45
@rombirli
rombirli removed this pull request from stack #6570 November 25, 2026 20:47
@rombirli
rombirli added this pull request to stack #6589 November 25, 2026 20:48
@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch from ee828cc to efc48da Compare November 25, 2026 20:57
@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch from efc48da to f827f32 Compare November 25, 2026 21:26
@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch from f827f32 to f0fa67c Compare November 25, 2026 21:28
@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch from f0fa67c to a3ce590 Compare November 27, 2026 07:55
@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch from a3ce590 to 9238414 Compare November 27, 2026 08:29
@rombirli
rombirli force-pushed the rombirli/semsitter-feature-flags branch from 9238414 to f39d27c Compare November 27, 2026 09:24
@gitar-bot

gitar-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk 1 closed / 1 findings

Adding project-scoped LaunchDarkly evaluation makes feature selection remotely configurable, so callers may choose different analysis behavior when flag values change.

Adds a LaunchDarkly client that reads one boolean feature flag per project through a single HTTPS call to the client-side evaluation endpoint, returning the default on any failure. The previously flagged unclosed HttpClient after the one-shot fetch has been addressed. No open issues remain.

✅ 1 closed
✅ Quality: HttpClient is never closed after the one-shot flag fetch

📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/LaunchDarklyFeatureFlags.java:75-80
The project targets JDK 21 (jdk.min.version 21 in the root pom). Since JDK 21, java.net.http.HttpClient implements AutoCloseable. fetch builds a new client on every connect and never closes it, on success, on a non-200 status, on a parse failure or on interruption. The client's selector-manager thread and its pooled connection stay alive until the client is garbage-collected, inside the analysis JVM. This repo ships a TryWithResources rule that flags exactly this Java 21 HttpClient pattern (TryWithResourcesCheck_java_21.java). Wrap the client in try-with-resources.

Verification Rules 3/3 met Repos 1 inspected · PRs 2 inspected

Functional validation No results

Rules 3 passed 2 not applicable

✅ Internal artifact registries
✅ Release secrets usage
✅ Repository license compliance

Broader impact Repos 1 inspected PRs 2 inspected
Cross-repo 1 repository inspected 0 open impacts

SonarSource/sonar-java-symbolic-execution Inspected

Cross-PR 2 PRs inspected 0 open impacts

PR 6583: JAVA-7406 Offer the SemSitter frontend behind a flag Inspected
PR 6553: SONARJAVA-7339 Parse with the SemSitter translator behind the feature flag Inspected

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqube-next

Copy link
Copy Markdown
Contributor

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant