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.

Intent

Register SemSitterParserProvider (the JParserProvider of PR1) and package the module in the plugin. The SemSitter frontend is used only when an executable is known and the property or the flag enables it.

flowchart TD
  C[configure] --> E{executable known?<br/>sonar.java.semsitter.executable or SEMSITTER_ANALYZER}
  E -->|no| ECJ[ECJ]
  E -->|yes| P{sonar.java.semsitter.enabled set?}
  P -->|true| SS[SemSitterParser]
  P -->|false| ECJ
  P -->|unset| F{LaunchDarkly flag on for the project?}
  F -->|yes| SS
  F -->|no or failure| ECJ
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

No executable is configured anywhere, so ECJ keeps parsing everything.

Test plan

  • SemSitterParserProviderTest: executable, property, flag, flag failure, project key

@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 from 8aa5c01 to cd5f32a Compare November 25, 2026 20:57
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from cd5f32a to db45578 Compare November 25, 2026 21:26
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from db45578 to b6e5724 Compare November 25, 2026 21:28
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from b6e5724 to 8f11118 Compare November 27, 2026 07:55
@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from 8f11118 to 6c305e3 Compare November 27, 2026 08:29
@datadog-sonarsource

This comment has been minimized.

@rombirli
rombirli force-pushed the rombirli/semsitter-provider-flag branch from 6c305e3 to 748e974 Compare November 27, 2026 09:24
@gitar-bot

gitar-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown
CI failed: The Ruling Update and Notify job failed because the ruling QA job was cancelled, so no actual_* artifacts were available to download. The log does not show why QA was cancelled, and the finding is not attributed to this PR's SemSitter changes.

Overview

The Ruling Update and Notify job failed because the ruling QA job was cancelled, so no actual_* artifacts were available to download. The log does not show why QA was cancelled, and the finding is not attributed to this PR's SemSitter changes.

Failures

Ruling Update and Notify job failed after ruling QA was cancelled and no actual_* artifacts were downloaded (job 140420196538)

  • Type: infrastructure
  • Affected jobs: 140420196538
  • Related to change: no
  • Confidence: high
  • Root cause: The workflow detected the ruling QA result as cancelled and set RULING_FAILED=true. The artifact sync step then failed with “No artifacts were downloaded” (exit code 1), a downstream consequence of the missing artifacts. The log does not show why ruling QA was cancelled. The PR adds the SemSitter parser provider and packaging, but there is no evidence connecting those changes to the cancellation or artifact-download failure.
  • Suggested fix: Investigate why the ruling QA job was cancelled and rerun it if appropriate. Ensure successful QA jobs upload the expected actual_* artifacts, and consider making the notification workflow handle cancelled jobs without attempting to download unavailable artifacts.

Summary

  • Change-related failures: 0
  • Infrastructure/flaky failures: 1
  • Recommended action: Investigate why the ruling QA job was cancelled and rerun it if appropriate. Ensure successful QA jobs upload the expected actual_* artifacts, and consider making the notification workflow handle cancelled jobs without attempting to download unavailable artifacts.
Code Review ✅ Approved 🟡 Medium risk 2 closed / 2 findings

Registering the flag-controlled SemSitter parser changes frontend selection for enabled projects, which could alter Java parsing and analysis results.

Offers the SemSitter frontend when an executable is configured and either sonar.java.semsitter.enabled or the LaunchDarkly flag enables it, registering SemSitterParserProvider and packaging the module into the plugin. Flag lookups are cached per provider, so a failed or timed-out read can keep a project on ECJ for the life of the JVM and ignore later flag changes in long-lived hosts. Caching should be scoped per analysis, or failed and empty reads should not be cached, before merge.

LaunchDarkly is no longer queried again for every module of the same project, which was addressed this session.

✅ 2 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.

Verification Rules 3/3 met Repos 3 inspected · PRs 4 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 4 inspected
Cross-repo 3 repositories inspected 0 open impacts

SonarSource/sonar-iac Inspected
SonarSource/sonarlint-eclipse Inspected
SonarSource/sonarlint-intellij Inspected

Cross-PR 4 PRs inspected 0 open impacts

PR 6582: JAVA-7405 Read the SemSitter frontend flag from LaunchDarkly Inspected
PR 6567: JAVA-7393 Let the Java frontend be swapped through a parser provider Inspected
PR 6568: JAVA-7394 Add the SemSitter frontend module and its protocol client Inspected
PR 6569: JAVA-7395 Run a SemSitter parsing session Inspected

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

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