Skip to content

SONARJAVA-6764 Implement cache for BeanDefinitionGatherer - #5934

Merged
NoemieBenard merged 5 commits into
epic-SONARJAVA-6237from
nb/sonarjava-6764
Aug 18, 2026
Merged

NoemieBenard merged 5 commits into
epic-SONARJAVA-6237from
nb/sonarjava-6764

Conversation

@NoemieBenard

@NoemieBenard NoemieBenard commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary by Gitar

  • Caching:
    • Implemented caching mechanism for BeanDefinitionGatherer in BeanDefinitionGatherer.java
    • Added comprehensive unit tests covering cache hits, misses, serialization, and error handling

This will update automatically on new commits.

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

SONARJAVA-6764

@sonarqube-next

Copy link
Copy Markdown
Contributor

@NoemieBenard
NoemieBenard marked this pull request as ready for review August 18, 2026 09:31

@asya-vorobeva asya-vorobeva left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@NoemieBenard
NoemieBenard merged commit b80be88 into epic-SONARJAVA-6237 Aug 18, 2026
27 of 28 checks passed
@NoemieBenard
NoemieBenard deleted the nb/sonarjava-6764 branch August 18, 2026 15:18
@gitar-bot

gitar-bot Bot commented Aug 18, 2026

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

Implements a caching mechanism for BeanDefinitionGatherer along with comprehensive unit tests. The potential unhealable corrupted cache entry issue was successfully addressed.

✅ 1 resolved
Bug: Corrupted cache entry never self-heals after re-parse

📄 java-frontend/src/main/java/org/sonar/java/model/springcontext/BeanDefinitionGatherer.java:199-212 📄 java-frontend/src/main/java/org/sonar/java/model/springcontext/BeanDefinitionGatherer.java:144-155 📄 java-frontend/src/main/java/org/sonar/java/model/springcontext/BeanDefinitionGatherer.java:186-190
In readFromCache, copyFromPrevious(cacheKey) is called (line 199) before deserialization. When deserialization fails (corrupt entry, or a future serialization-format change), the catch returns Optional.empty() so scanWithoutParsing returns false and the file is re-parsed. But copyFromPrevious has already registered the (stale/corrupt) entry under cacheKey in the write cache, so leaveFile's writeToCache call hits the duplicate-key IllegalArgumentException and is silently swallowed. The freshly parsed data is discarded and the corrupt entry is carried forward on every subsequent incremental analysis, so it never recovers — and on a format change this affects all files at once, permanently serving stale bean definitions. Move copyFromPrevious to only run after successful deserialization (or skip it on the failure path) so re-parsed files can rewrite their cache entry.

Options

Auto-apply is off → Gitar will not 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:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

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.

3 participants