Skip to content

SONARJAVA-7095 Implement JSON serialization for the common Spring context gathering model - #6283

Open
aurelien-coet-sonarsource wants to merge 1 commit into
ac/SONARJAVA-7095from
ac/SONARJAVA-7095-2
Open

aurelien-coet-sonarsource wants to merge 1 commit into
ac/SONARJAVA-7095from
ac/SONARJAVA-7095-2

Conversation

@aurelien-coet-sonarsource

@aurelien-coet-sonarsource aurelien-coet-sonarsource commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary by Gitar

  • Serialization:
    • Added SpringContextGatheringModelTypeAdapter for serializing Spring context gathering models.
    • Implemented type adapters and json adapters for BeanDefinitionHolder and InjectionPoint records.

This will update automatically on new commits.

@aurelien-coet-sonarsource
aurelien-coet-sonarsource added this pull request to stack #6284 October 1, 2026 11:38
@aurelien-coet-sonarsource aurelien-coet-sonarsource changed the title Implement JSON serialization for the common Spring context gathering … SONARJAVA-7095 Implement JSON serialization for the common Spring context gathering model Oct 1, 2026
@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title SONARJAVA-7095 Implement JSON serialization for the common Spring context gathering model SONARJAVA-7113 Implement JSON serialization for the common Spring context gathering … Oct 1, 2026
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

SONARJAVA-7095

@aurelien-coet-sonarsource aurelien-coet-sonarsource changed the title SONARJAVA-7113 Implement JSON serialization for the common Spring context gathering … SONARJAVA-7095 Implement JSON serialization for the common Spring context gathering model Oct 1, 2026
@aurelien-coet-sonarsource
aurelien-coet-sonarsource force-pushed the ac/SONARJAVA-7095-2 branch 2 times, most recently from 8408443 to 3cfac26 Compare October 1, 2026 12:30
@sonarqube-next

sonarqube-next Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

@gitar-bot

gitar-bot Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
CI failed: CI build failed due to an external infrastructure issue (HTTP 503 Service Unavailable) when querying the SonarQube server version.

Overview

1 log was analyzed, revealing an infrastructure failure during the SonarQube scanner plugin execution.

Failures

SonarQube Server 503 Service Unavailable (confidence: high)

  • Type: infrastructure
  • Affected jobs: 111742826414
  • Related to change: no
  • Root cause: The Maven build failed during the sonar:sonar goal execution because the SonarQube server returned HTTP 503 Service Unavailable when attempting to query its version.
  • Suggested fix: Retry the CI job once the SonarQube server is available and healthy.

Summary

  • Change-related failures: 0 failures
  • Infrastructure/flaky failures: 1 infrastructure failure due to SonarQube server unavailability (HTTP 503)
  • Recommended action: Re-run the CI pipeline.
Code Review ✅ Approved 1 closed / 1 findings

🟡 Medium risk · Adds JSON round-tripping for Spring context data across modules and files

Implements JSON serialization for the Spring context gathering model with a custom SpringContextGatheringModelTypeAdapter to handle module and file-level context data. The @JsonAdapter bean round-trip issue under Gson's default null handling has been resolved, and comprehensive unit tests cover round-trips, missing properties, and empty modules. Ready to merge.

✅ 1 closed
✅ Bug: @JsonAdapter bean round-trip fails under Gson's default null handling

📄 java-frontend/src/main/java/org/sonar/java/model/springcontext/BeanDefinitionHolder.java:238 📄 java-frontend/src/main/java/org/sonar/java/serialization/SpringContextGatheringModelTypeAdapter.java:55-56
The new @JsonAdapter(BeanDefinitionHolderTypeAdapter.class) lets anyone call new Gson().toJson(bean) / fromJson(json, BeanDefinitionHolder.InputFileData.class) directly. The adapter's write relies on the caller having turned on serializeNulls. Today only SpringContextGatheringModelTypeAdapter.write does that (and possibly the cache helper's own writer). A default Gson writer has serializeNulls=false, so out.name(PROFILES).value((String) null) drops both the name and the value for every unconditional bean, and so does a null qualifier. read then throws missingProperty(PROFILES) because profilesRead stays false. That means the standalone round-trip this annotation advertises fails for the most common kind of bean (one with no @Profile). Fix: have BeanDefinitionHolderTypeAdapter.write save out.getSerializeNulls(), force it to true, and restore it in a finally, the same way the model adapter does. Alternatively, treat a missing profiles key as unconditional.

Review coverage

🧪 Functional validation 2 of 2 objectives covered

📋 Rules No rules evaluated

Cross-repo coverage 1 repository selected

Cross-repo inspection is incomplete. Unread code may contain additional impacts.

🤖 Auto-approval Not enabled · Set up

Implementation Status ✅ 2 of 2 objectives covered
✅ SONARJAVA-7095 - 2 of 2 objectives covered

This PR implements JSON serialization and de-serialization for the Spring context gathering model.

✅ 2 covered here
  • ✅ Implement on-disk serialization for the Spring context model
  • ✅ Implement on-disk de-serialization for the Spring context model

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 → Counting what did not apply, without listing it.

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

@datadog-sonarsource

datadog-sonarsource Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Pipelines

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 1 Pipeline job failed

Build | Test Analyze

View more details · View in GitHub Actions

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c95e8f0 | Docs | View more details | Give us feedback!

@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.

💯

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.

2 participants