Repository navigation
SONARJAVA-7197 Log when no Spring context model file is found at the start of an analysis - #6366
aurelien-coet-sonarsource wants to merge 3 commits into
Conversation
| if (!Files.exists(path)) { | ||
| LOG.warn("Spring context model file does not exist: {}. Starting with an empty Spring context.", path); | ||
| return new SpringContextGatheringModel(); |
There was a problem hiding this comment.
💡 Quality: WARN fires on every first analysis and every non-Spring Java project
JavaSensor.execute calls SpringContextModelPersistence.load(path) on every Java analysis, with nothing checking whether the project uses Spring. The default path is .sonar/spring-context-model.json, which won't exist on a project's first analysis, on CI agents that don't cache .sonar/, or for any project where the model was never written. In all of those cases the new line logs at WARN even though nothing is wrong, so users see warnings they can't act on and real warnings get harder to spot. Log this expected state at INFO or DEBUG. Keep WARN for the read/parse failure branch below, which is a real problem.
Log the missing file, which is expected, at INFO (or DEBUG) instead of WARN.:
LOG.info("Spring context model file does not exist: {}. Starting with an empty Spring context.", path);
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
66f69a2 to
f1de927
Compare
29019c6 to
eae0c45
Compare
Code Review 👍 Approved with suggestions 0 closed / 1 findings🟢 Low risk · Adds diagnostic logs for missing or restored Spring context models; restoration behavior remains unchanged, limiting impact to analysis output. Adds logging around Spring context model loading at analysis start, including a warning when the model file is missing and an info log on successful restore. Consider lowering the missing-file message from WARN to INFO or DEBUG, since first analyses and non-Spring projects will hit it routinely and the WARN would be noise; keep WARN for read/parse failures. 💡 Quality: WARN fires on every first analysis and every non-Spring Java project📄 sonar-java-plugin/src/main/java/org/sonar/plugins/java/SpringContextModelPersistence.java:50-52
Log the missing file, which is expected, at INFO (or DEBUG) instead of WARN.🤖 Prompt for agentsVerification Rules 1/1 met Repos 2 inspected · PRs 1 inspectedFunctional validation No results Rules 1 passed 2 not applicable
Broader impact Repos 2 inspected PRs 1 inspectedCross-repo 2 repositories inspected 0 open impacts
Cross-PR 1 PR inspected 0 open impactsAuto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|




Summary by Gitar
This will update automatically on new commits.