Skip to content

JAVA-7406 Offer the SemSitter frontend behind a flag - #6583

Open
rombirli wants to merge 3 commits into
rombirli/semsitter-feature-flagsfrom
rombirli/semsitter-provider-flag
Open

rombirli wants to merge 3 commits into
rombirli/semsitter-feature-flagsfrom
rombirli/semsitter-provider-flag

Conversation

@rombirli

@rombirli rombirli commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part 16 of 17 of JAVA-7392. Ticket: JAVA-7406.

$\color{red}{\textbf{CONTRACT WITH SONARQUBE CLOUD: sonar.java.internal.semsitter.enabled}}$

SonarQube Cloud must send this context property to turn the SemSitter frontend on. Its name is defined once, in SemSitterFlag.ENABLED_PROPERTY. Renaming it requires the same change in SonarQube Cloud.

Intent

Register SemSitterParserProvider (the JParserProvider of PR1) and package the module in the plugin. SonarQube Cloud turns the SemSitter frontend on through the context property. An analysis that asks for it gets it or fails: there is no fallback to ECJ.

flowchart TD
  C[configure] --> P{sonar.java.internal.semsitter.enabled}
  P -->|false or absent| ECJ[ECJ]
  P -->|true| E{executable known?<br/>sonar.java.semsitter.executable or SEMSITTER_ANALYZER}
  E -->|yes| SS[SemSitterParser]
  E -->|no or blank| F[analysis fails: IllegalStateException]
Loading
JParser create(...) {
  return new SemSitterParser(mode, javaVersion, classpath, root -> SemSitterClient.start(server, root), translator);   // never falls back to ECJ
}

Plugin: dependency on java-frontend-semsitter, shading filter, license files of analyzer-wire and protobuf-java, and a max jar size raised to 24 MB.

State on master

SonarQube Cloud does not send the property yet, so ECJ keeps parsing everything. An executable alone does not turn the frontend on.

Test plan

  • SemSitterParserProviderTest: flag on without an executable fails (property and environment named in the message), blank executable counts as none, flag off or absent keeps ECJ, executable from the property and from the environment, reconfiguration, created parser

@hashicorp-vault-sonar-prod

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

Copy link
Copy Markdown
Contributor

JAVA-7406

@rombirli
rombirli added this pull request to stack #6570 November 25, 2026 11:48
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from f926156 to f6fcc26 Compare November 25, 2026 12:00
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch 2 times, most recently from 443ce78 to db342cb Compare November 25, 2026 13:08
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch 2 times, most recently from 2a388ae to 9b58b2e Compare November 25, 2026 14:14
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch 2 times, most recently from c6e5aeb to 113ddba Compare November 25, 2026 15:32
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from 113ddba to b2b522f Compare November 25, 2026 16:31
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch 2 times, most recently from 23378b5 to 3905597 Compare November 25, 2026 18:03
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from 3905597 to f661a33 Compare November 25, 2026 18:39
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from f661a33 to 8aa5c01 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-provider-flag branch 2 times, most recently from 8714987 to f8547df Compare November 30, 2026 15:51
@rombirli
rombirli removed this pull request from stack #6589 December 1, 2026 11:07
@rombirli
rombirli added this pull request to stack #6607 December 1, 2026 11:08
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from f8547df to b625fd0 Compare December 2, 2026 13:52
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from b625fd0 to 458c30b Compare December 2, 2026 14:21
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from 458c30b to 81dec85 Compare December 2, 2026 14:46
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from 81dec85 to 3cc77ee Compare December 2, 2026 15:04
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from 3cc77ee to 90c4f6f Compare December 2, 2026 15:20
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from 90c4f6f to 1cf96ca Compare December 2, 2026 15:31
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from 1cf96ca to 9e067e2 Compare December 2, 2026 16:15
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from 9e067e2 to 6abbc8c Compare December 2, 2026 16:42
@gitar-bot

gitar-bot Bot commented Dec 2, 2026 •

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

Registering the SemSitter parser behind a Cloud flag changes Java parsing when enabled; configuration or parser issues could fail analyses.

Registers the SemSitter parser provider behind the sonar.java.internal.semsitter.enabled flag and packages the frontend and its licenses in the plugin. Approved with one open suggestion: the PR description flowchart and test plan still describe the old ECJ fallback, while the code now fails the analysis when the flag is on and no executable is configured. Update the description to match the fail-fast behaviour.

✅ 4 closed
✅ Performance: LaunchDarkly is queried again for every module of the same project

📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/SemSitterParserProvider.java:71-85
JavaSensor is a plain Sensor, not a @ProjectSensor, so it runs once per module. Each run calls JParserProviders.configure, which calls SemSitterParserProvider.configure. Whenever an executable and a client ID are set and sonar.java.semsitter.enabled is not, isFlagOn calls flags.connect(...). That opens a new HttpClient and sends a blocking request with a 3s connect timeout and a 3s request timeout, every time. The project key is the same for every module, so every module repeats the same lookup. On a CI host that cannot reach LaunchDarkly, a project with N modules waits up to ~3–6s per module, so N×3–6s in total, just to read a flag value that never changes.

Fix: cache the flag result per (clientId, projectKey) inside the provider. Reuse it when configure runs again for the same project, and look the flag up again only when the key changes.

Closed: Edge Case: A failed or timed-out flag read is cached for the life of the JVM

📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/SemSitterParserProvider.java:60 📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/SemSitterParserProvider.java:93 📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/SemSitterParserProvider.java:96-104
flagValues is an instance map with no expiry. The provider is created once and held in the static JParserProviders.DISCOVERED list, so the map lasts as long as the plugin classloader. readFlag stores FLAG_DEFAULT when the lookup throws. LaunchDarklyFeatureFlags.connect also swallows unreachable, timeout and non-200 errors and returns empty flags, which evaluate to false, and that value is cached too. In a long-lived host that reuses the plugin across analyses, such as SonarLint or a daemonized scanner, one transient LaunchDarkly outage keeps the project on ECJ until the process restarts. Turning the flag on or off in LaunchDarkly also has no effect until then. To fix this, cache only for the current analysis, for example by clearing the map when the project changes or giving entries a TTL, or skip caching when the read failed or returned no flags.

Closed: Quality: PR description still promises a LaunchDarkly lookup the code dropped

📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/SemSitterParserProvider.java:32-36 📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/SemSitterParserProvider.java:58-71 📄 java-frontend-semsitter/src/test/java/org/sonar/java/semsitter/SemSitterParserProviderTest.java:82-89
The PR description no longer matches the code. It says that when sonar.java.semsitter.enabled is unset, the provider asks LaunchDarkly whether the flag is on for the project. Its test plan also lists flag-failure and project-key tests. The code does something different: configure only reads SemSitterFlag.isEnabled, which checks sonar.java.internal.semsitter.enabled (a different property name) and otherwise uses DEFAULT = false. SemSitterFlag's own javadoc says the analyzer "never reaches out to a flag service", and SemSitterParserProviderTest has no flag-failure or project-key cases.

Reviewers and operators who follow the description will set the wrong property, and they will expect LaunchDarkly to turn the frontend on when nothing will. Please update the description's flowchart, property name and test plan to match the property-only behaviour.

Closed: Quality: PR description flowchart still says no executable falls back to ECJ

📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/SemSitterParserProvider.java:33-36 📄 java-frontend-semsitter/src/main/java/org/sonar/java/semsitter/SemSitterParserProvider.java:63-71
This commit changes configure to read the flag first. When sonar.java.internal.semsitter.enabled=true and no executable is known (neither sonar.java.semsitter.executable nor SEMSITTER_ANALYZER), it now throws an IllegalStateException and fails the analysis (lines 63-68, tested by flag_on_without_executable_fails_instead_of_leaving_the_analysis_to_another_frontend). The PR description's flowchart still checks the executable first and sends no to ECJ whatever the flag says. Its test plan also still lists "executable (property, environment, blank)" as plain enable/disable cases. Someone on the SonarQube Cloud side who relies on this property contract would expect turning the flag on without an executable to keep ECJ, but the analysis fails instead. Update the flowchart so the flag decision comes first, with true + no executable leading to "fail analysis", and mention the fail-fast behaviour in the Intent section.

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

Functional validation No results

Rules 3 passed 2 not applicable

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

Broader impact Repos 3 inspected PRs 3 inspected
Cross-repo 3 repositories inspected 0 open impacts

SonarSource/sonarlint-intellij Inspected
SonarSource/sonarlint-language-server Inspected
SonarSource/sonar-iac Inspected

Cross-PR 3 PRs inspected 0 open impacts

PR 6553: SONARJAVA-7339 Parse with the SemSitter translator behind the feature flag Inspected
PR 6569: JAVA-7395 Run a SemSitter parsing session Inspected
PR 6568: JAVA-7394 Add the SemSitter frontend module and its protocol client 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

sonarqube-next Bot commented Dec 2, 2026

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