Skip to content

SONARJAVA-6931 ci-autofix: Investigate red master CI - #6107

Closed
hashicorp-vault-sonar-prod[bot] wants to merge 3 commits into
masterfrom
ci-autofix/102448842840
Closed

SONARJAVA-6931 ci-autofix: Investigate red master CI#6107
hashicorp-vault-sonar-prod[bot] wants to merge 3 commits into
masterfrom
ci-autofix/102448842840

Conversation

@hashicorp-vault-sonar-prod

@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

The latest CI run on master is red: SonarQube Code Analysis (run 102448842840).

This PR was opened with an empty commit to reserve a place for the CI fix.

@hashicorp-vault-sonar-prod

Copy link
Copy Markdown
Contributor Author

gitar auto-apply:on

@hashicorp-vault-sonar-prod

Copy link
Copy Markdown
Contributor Author

gitar master CI is failing https://next.sonarqube.com/sonarqube/dashboard?id=org.sonarsource.java%3Ajava&branch=master. Investigate the failure and fix it in this PR if possible. If not, leave a comment with your investigation results.

@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title ci-autofix: Investigate red master CI SONARJAVA-6931 ci-autofix: Investigate red master CI Sep 9, 2026
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

SONARJAVA-6931

gitar-bot and others added 2 commits September 9, 2026 14:42
Use Objects.equals instead of expectedMessage.equals to defensively
guard against a null expectedMessage, addressing the SonarQube
Reliability finding (S2259) that failed the master Quality Gate.
Co-authored-by: hashicorp-vault-sonar-prod[bot] <111297361+hashicorp-vault-sonar-prod[bot]@users.noreply.github.com>
@gitar-bot

gitar-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

Investigated the red master CI. The failing check is the SonarQube Code Analysis job, which failed the Quality Gate on two conditions: Reliability Rating (E) and 1 open issue.

The open issue is javabugs:S2259 (Fix this access that will throw a NullPointerException when executed) at java-checks-testkit/src/main/java/org/sonar/java/checks/verifier/internal/InternalCheckVerifier.java:407, in assertComponentIssue:

if (!expectedMessage.equals(issue.getMessage())) {

expectedMessage comes from expectations.expectedFileIssue()/expectedProjectIssue(), which default to null in Expectations. The caller only invokes this method when expectIssueAtFileLevel() || expectIssueAtProjectLevel() is true, so in practice expectedMessage is never null here — but the analyzer can't verify that invariant across methods, hence the reliability finding.

Fixed by using Objects.equals(expectedMessage, issue.getMessage()) instead, which removes the potential NPE without changing behavior.

@gitar-bot

gitar-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Adds null-check guard on an unreachable path in InternalCheckVerifier.assertComponentIssue to resolve the SonarQube code analysis failure on master. No issues found.

✅ 1 resolved
Quality: NPE guard added on unreachable path; real nullable deref untouched

📄 java-checks-testkit/src/main/java/org/sonar/java/checks/verifier/internal/InternalCheckVerifier.java:407 📄 java-checks-testkit/src/main/java/org/sonar/java/checks/verifier/internal/InternalCheckVerifier.java:351 📄 java-checks-testkit/src/main/java/org/sonar/java/checks/verifier/internal/InternalCheckVerifier.java:384-393 📄 java-checks-testkit/src/main/java/org/sonar/java/checks/verifier/internal/InternalCheckVerifier.java:486-498
At line 407 expectedMessage cannot be null: assertComponentIssue is only invoked from checkIssues when expectIssueAtFileLevel() || expectIssueAtProjectLevel() (line 351), and both are StringUtils.isNotEmpty(...) checks (Expectations.java:271-284), so the branch assigning expectedMessage always yields a non-empty string. The change is therefore behaviour-neutral (and would make a hypothetical null-expected/null-actual pair silently pass verification), while the analogous, actually reachable dereference of the nullable AnalyzerMessage.getMessage() remains: validateAnalyzerMessageAttributes passes analyzerMessage.getMessage() (line 498) into assertAttributeMatch, which calls value.equals(...) unguarded (line 487) — a check reporting an issue with a null message NPEs there instead of producing an assertion failure. If the red-CI issue this PR targets is the nullable-message comparison, fixing only line 407 will not clear it.

Options ✅ Auto-apply

✅ Auto-apply is on → Gitar will commit updates to this branch.
Display: compact → Showing less information.

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

✅ Auto-apply Compact
gitar auto-apply:off         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@mary-georgiou
mary-georgiou deleted the ci-autofix/102448842840 branch September 9, 2026 14:45
@sonarqube-next

sonarqube-next Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

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.

2 participants