Skip to content

SONARJAVA-6410 Create SpringContextModel and related classes#5646

Merged
asya-vorobeva merged 5 commits into
epic-SONARJAVA-6237from
asya/basic-spring-context-model
Jun 1, 2026
Merged

SONARJAVA-6410 Create SpringContextModel and related classes#5646
asya-vorobeva merged 5 commits into
epic-SONARJAVA-6237from
asya/basic-spring-context-model

Conversation

@asya-vorobeva
Copy link
Copy Markdown
Contributor

@asya-vorobeva asya-vorobeva commented Jun 1, 2026

Create SpringContextModel and related classes. See SONARJAVA-6410.

asya-vorobeva and others added 2 commits June 1, 2026 13:09
Introduce the springcontext package with BeanDefinitionHolder,
BeanDefinitionRegistry, BeanLocation, EntityClassToPropertiesIndex,
ProjectPackageScan, SpringContextModel, and TypeToBeanNamesIndex.
All classes include Javadoc documentation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hashicorp-vault-sonar-prod
Copy link
Copy Markdown
Contributor

hashicorp-vault-sonar-prod Bot commented Jun 1, 2026

SONARJAVA-6410

@leonardo-pilastri-sonarsource leonardo-pilastri-sonarsource changed the base branch from master to epic-SONARJAVA-6237 June 1, 2026 12:23
@asya-vorobeva asya-vorobeva merged commit a1ce8d7 into epic-SONARJAVA-6237 Jun 1, 2026
11 of 12 checks passed
@asya-vorobeva asya-vorobeva deleted the asya/basic-spring-context-model branch June 1, 2026 12:36
@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented Jun 1, 2026

Code Review ✅ Approved 1 resolved / 1 findings

Implements SpringContextModel and supporting classes for the Spring context analysis engine. The builder has been updated to copy input lists, resolving the previous immutability violation.

✅ 1 resolved
Bug: Builder stores external list reference, breaking immutability

📄 java-frontend/src/main/java/org/sonar/java/model/springcontext/BeanDefinitionHolder.java:130-132 📄 java-frontend/src/main/java/org/sonar/java/model/springcontext/BeanDefinitionHolder.java:147
The class Javadoc declares BeanDefinitionHolder as an "Immutable representation", but the Builder.dependingBeans(List<String> beansList) method stores the caller's list reference directly. In build(), Collections.unmodifiableList(dependingBeans) creates an unmodifiable view over the original list — it does not copy it. If the caller mutates the original list after build() is called, the holder's internal state changes silently, violating the immutability contract.

A defensive copy is needed to guarantee true immutability.

Options

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

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqube-next
Copy link
Copy Markdown

sonarqube-next Bot commented Jun 1, 2026

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0 Dependency risks
No data about Coverage
No data about Duplication

See analysis details on SonarQube

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