-
Notifications
You must be signed in to change notification settings - Fork 724
SONARJAVA-6421 Implement S9352: Bean autowiring ambiguity should be resolved using "@Qualifier" or "@Primary" #6044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
NoemieBenard
wants to merge
22
commits into
epic-SONARJAVA-6237
from
nb/sonarjava-6421-ambiguous-dependency-rule
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3351066
Generate rule metadata
NoemieBenard 134d12b
Create test samples
NoemieBenard 048473e
Implement check
NoemieBenard 6017061
Add support for `@Fallback`
NoemieBenard a9b173b
Fix bug when one resolved injection point hides another ambiguous one
NoemieBenard 56b5849
Fix FP when qualifier is defined on the bean itself
NoemieBenard 44d349a
Fix duplicate issue bug
NoemieBenard 9558a3b
Fix FN when there are two `@Primary` candidates
NoemieBenard 95075b9
Fix test gap and incorrect comments
NoemieBenard 7224507
Update comments
NoemieBenard a0a90d3
Refactor project sensor to use Strategy design pattern
NoemieBenard da8696a
Create new structure for storing all collected dependencies
NoemieBenard 14b05cc
Refactor check to use TypeToDependenciesIndex
NoemieBenard d4085cb
Fix incorrect condition
NoemieBenard 2787db5
Fix test expectations
NoemieBenard e428ced
Fix FN when there are multiple matching candidates
NoemieBenard 3352b3a
Remove `@Qualifier` annotation on the bean definition
NoemieBenard dfcb733
Add cross-module tests
NoemieBenard 8fb01c5
Fix Spring dependency
NoemieBenard c946cf0
Update comments and clean up
NoemieBenard 43ad38d
Add javadoc for execute method
NoemieBenard 15e3ee1
Remove concurrent execution on ScannerIntegrationAbstractTest
NoemieBenard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...tion-tests/src/test/java/org/sonar/java/it/spring/AmbiguousDependencyCrossModuleTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * SonarQube Java | ||
| * Copyright (C) SonarSource Sàrl | ||
| * mailto:info AT sonarsource DOT com | ||
| * | ||
| * You can redistribute and/or modify this program under the terms of | ||
| * the Sonar Source-Available License Version 1, as published by SonarSource Sàrl. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| * See the Sonar Source-Available License for more details. | ||
| * | ||
| * You should have received a copy of the Sonar Source-Available License | ||
| * along with this program; if not, see https://sonarsource.com/license/ssal/ | ||
| */ | ||
| package org.sonar.java.it.spring; | ||
|
|
||
| import com.sonarsource.scanner.integrationtester.dsl.issue.TextRange; | ||
| import com.sonarsource.scanner.integrationtester.dsl.issue.TextRangeIssue; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.sonar.java.it.ScannerIntegrationAbstractTest; | ||
|
|
||
| import java.nio.file.Path; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class AmbiguousDependencyCrossModuleTest extends ScannerIntegrationAbstractTest { | ||
|
|
||
| @Test | ||
| void test() { | ||
| var issues = analyze(Path.of("ambiguous-dependencies-should-be-resolved"), "S9352"); | ||
| assertThat(issues) | ||
| .hasSize(5) | ||
| .contains(new TextRangeIssue( | ||
| "app/src/main/java/com/example/app/ReportingConsumer.java", | ||
| "java:S9352", | ||
| "Multiple beans match this dependency (excelReportingService, pdfReportingService); disambiguate it with \"@Qualifier\" or mark one bean as \"@Primary\".", | ||
| new TextRange(16, 16, 29, 45)), | ||
| new TextRangeIssue( | ||
| "app/src/main/java/com/example/app/CacheConsumer.java", | ||
| "java:S9352", | ||
| "Multiple beans match this dependency (diskCacheProvider, inMemoryCacheProvider, redisCacheProvider); disambiguate it with \"@Qualifier\" or mark one bean as \"@Primary\".", | ||
| new TextRange(12, 12, 26, 39)), | ||
| new TextRangeIssue( | ||
| "app/src/main/java/com/example/app/PaymentConsumer.java", | ||
| "java:S9352", | ||
| "Multiple beans match this dependency (creditCardPaymentGateway, digitalWalletPaymentGateway); disambiguate it with \"@Qualifier\" or mark one bean as \"@Primary\".", | ||
| new TextRange(15, 15, 27, 41)), | ||
| new TextRangeIssue( | ||
| "app/src/main/java/com/example/app/NotificationConsumer.java", | ||
| "java:S9352", | ||
| "Multiple beans match this dependency (emailNotificationService, smsNotificationService); disambiguate it with \"@Qualifier\" or mark one bean as \"@Primary\".", | ||
| new TextRange(16, 16, 32, 51)), | ||
| new TextRangeIssue( | ||
| "app/src/main/java/com/example/app/InventoryConsumer.java", | ||
| "java:S9352", | ||
| "Multiple beans match this dependency (storeInventoryService, warehouseInventoryService); disambiguate it with \"@Qualifier\" or mark one bean as \"@Primary\".", | ||
| new TextRange(12, 12, 29, 45))); | ||
| } | ||
| } |
37 changes: 37 additions & 0 deletions
37
...ntegration-tests/src/test/resources/ambiguous-dependencies-should-be-resolved/app/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <groupId>com.example</groupId> | ||
| <artifactId>ambiguous-dependencies-should-be-resolved</artifactId> | ||
| <version>0.0.1-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>app</artifactId> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.example</groupId> | ||
| <artifactId>module-common</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.example</groupId> | ||
| <artifactId>module-a</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.example</groupId> | ||
| <artifactId>module-b</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-autoconfigure</artifactId> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> |
13 changes: 13 additions & 0 deletions
13
...uous-dependencies-should-be-resolved/app/src/main/java/com/example/app/CacheConsumer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.example.app; | ||
|
|
||
| import com.example.common.CacheProvider; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| // CASE: ambiguity between three @Bean-method-declared beans (not @Component), same module. | ||
| @Component | ||
| public class CacheConsumer { | ||
|
|
||
| @Autowired | ||
| private CacheProvider cacheProvider; | ||
| } |
16 changes: 16 additions & 0 deletions
16
...us-dependencies-should-be-resolved/app/src/main/java/com/example/app/CarrierConsumer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.example.app; | ||
|
|
||
| import com.example.common.ShippingCarrier; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| /** | ||
| * CASE: ambiguity resolved via @Primary, cross-module. | ||
| * PrimaryCarrier (@Primary) lives in module-a, SecondaryCarrier in module-b. | ||
| */ | ||
| @Component | ||
| public class CarrierConsumer { | ||
|
|
||
| @Autowired | ||
| private ShippingCarrier shippingCarrier; | ||
| } |
19 changes: 19 additions & 0 deletions
19
...s-dependencies-should-be-resolved/app/src/main/java/com/example/app/DiscountConsumer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.example.app; | ||
|
|
||
| import com.example.common.DiscountService; | ||
| import org.springframework.beans.factory.annotation.Qualifier; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| /** | ||
| * CASE: ambiguity resolved via @Qualifier on a constructor parameter, cross-module. | ||
| * StandardDiscountService lives in module-a, PremiumDiscountService in module-b. | ||
| */ | ||
| @Component | ||
| public class DiscountConsumer { | ||
|
|
||
| private final DiscountService discountService; | ||
|
|
||
| public DiscountConsumer(@Qualifier("premiumDiscountService") DiscountService discountService) { | ||
| this.discountService = discountService; | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
...-dependencies-should-be-resolved/app/src/main/java/com/example/app/InventoryConsumer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.example.app; | ||
|
|
||
| import com.example.common.InventoryService; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| // CASE: ambiguity between two @Bean-method-declared beans, each in its own @Configuration class, cross-module. | ||
| @Component | ||
| public class InventoryConsumer { | ||
|
|
||
| @Autowired | ||
| private InventoryService inventoryService; | ||
| } |
17 changes: 17 additions & 0 deletions
17
...pendencies-should-be-resolved/app/src/main/java/com/example/app/NotificationConsumer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.example.app; | ||
|
|
||
| import com.example.common.NotificationService; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| /** | ||
| * CASE: unresolved ambiguity, same module. | ||
| * EmailNotificationService and SmsNotificationService (module-a) are both | ||
| * plain beans with no @Primary/@Qualifier - ambiguous. | ||
| */ | ||
| @Component | ||
| public class NotificationConsumer { | ||
|
|
||
| @Autowired | ||
| private NotificationService notificationService; | ||
| } |
15 changes: 15 additions & 0 deletions
15
...s-should-be-resolved/app/src/main/java/com/example/app/NotificationQualifiedConsumer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.example.app; | ||
|
|
||
| import com.example.common.NotificationService; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.beans.factory.annotation.Qualifier; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| // CASE: ambiguity resolved via @Qualifier, same module. | ||
| @Component | ||
| public class NotificationQualifiedConsumer { | ||
|
|
||
| @Autowired | ||
| @Qualifier("smsNotificationService") | ||
| private NotificationService notificationService; | ||
| } |
16 changes: 16 additions & 0 deletions
16
...us-dependencies-should-be-resolved/app/src/main/java/com/example/app/PaymentConsumer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.example.app; | ||
|
|
||
| import com.example.common.PaymentGateway; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| /** | ||
| * CASE: unresolved ambiguity, cross-module. | ||
| * CreditCardPaymentGateway lives in module-a, DigitalWalletPaymentGateway in module-b. | ||
| */ | ||
| @Component | ||
| public class PaymentConsumer { | ||
|
|
||
| @Autowired | ||
| private PaymentGateway paymentGateway; | ||
| } |
13 changes: 13 additions & 0 deletions
13
...us-dependencies-should-be-resolved/app/src/main/java/com/example/app/PricingConsumer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.example.app; | ||
|
|
||
| import com.example.common.PricingService; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| // CASE: ambiguity resolved via @Primary, same module. | ||
| @Component | ||
| public class PricingConsumer { | ||
|
|
||
| @Autowired | ||
| private PricingService pricingService; | ||
| } |
17 changes: 17 additions & 0 deletions
17
...-dependencies-should-be-resolved/app/src/main/java/com/example/app/ReportingConsumer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.example.app; | ||
|
|
||
| import com.example.common.ReportingService; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| /** | ||
| * CASE: two beans both marked @Primary, same module - still ambiguous. | ||
| * Having more than one "primary" candidate is itself unresolved: Spring | ||
| * throws NoUniqueBeanDefinitionException rather than picking either one. | ||
| */ | ||
| @Component | ||
| public class ReportingConsumer { | ||
|
|
||
| @Autowired | ||
| private ReportingService reportingService; | ||
| } |
11 changes: 11 additions & 0 deletions
11
...encies-should-be-resolved/app/src/main/java/com/example/app/SpringExampleApplication.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.example.app; | ||
|
|
||
| import org.springframework.boot.SpringApplication; | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
|
||
| @SpringBootApplication(scanBasePackages = "com.example") | ||
| public class SpringExampleApplication { | ||
| public static void main(String[] args) { | ||
| SpringApplication.run(SpringExampleApplication.class, args); | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
...ation-tests/src/test/resources/ambiguous-dependencies-should-be-resolved/module-a/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <groupId>com.example</groupId> | ||
| <artifactId>ambiguous-dependencies-should-be-resolved</artifactId> | ||
| <version>0.0.1-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>module-a</artifactId> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.example</groupId> | ||
| <artifactId>module-common</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springframework</groupId> | ||
| <artifactId>spring-context</artifactId> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> |
24 changes: 24 additions & 0 deletions
24
...pendencies-should-be-resolved/module-a/src/main/java/com/example/modulea/CacheConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.example.modulea; | ||
|
|
||
| import com.example.common.CacheProvider; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| @Configuration | ||
| public class CacheConfig { | ||
|
|
||
| @Bean | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's configure these beans in different modules / files to be sure that it recognizes such cases. |
||
| public CacheProvider redisCacheProvider() { | ||
| return key -> "redis:" + key; | ||
| } | ||
|
|
||
| @Bean | ||
| public CacheProvider inMemoryCacheProvider() { | ||
| return key -> "memory:" + key; | ||
| } | ||
|
|
||
| @Bean | ||
| public CacheProvider diskCacheProvider() { | ||
| return key -> "disk:" + key; | ||
| } | ||
| } | ||
12 changes: 12 additions & 0 deletions
12
...ould-be-resolved/module-a/src/main/java/com/example/modulea/CreditCardPaymentGateway.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.example.modulea; | ||
|
|
||
| import com.example.common.PaymentGateway; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| public class CreditCardPaymentGateway implements PaymentGateway { | ||
| @Override | ||
| public void charge(double amount) { | ||
| System.out.println("Charging credit card: " + amount); | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
...ould-be-resolved/module-a/src/main/java/com/example/modulea/EmailNotificationService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.example.modulea; | ||
|
|
||
| import com.example.common.NotificationService; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| public class EmailNotificationService implements NotificationService { | ||
| @Override | ||
| public void send(String message) { | ||
| System.out.println("Email: " + message); | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
...-should-be-resolved/module-a/src/main/java/com/example/modulea/ExcelReportingService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.example.modulea; | ||
|
|
||
| import com.example.common.ReportingService; | ||
| import org.springframework.context.annotation.Primary; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Primary | ||
| @Component | ||
| public class ExcelReportingService implements ReportingService { | ||
| @Override | ||
| public String generate() { | ||
| return "excel-report"; | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
...es-should-be-resolved/module-a/src/main/java/com/example/modulea/PdfReportingService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.example.modulea; | ||
|
|
||
| import com.example.common.ReportingService; | ||
| import org.springframework.context.annotation.Primary; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Primary | ||
| @Component | ||
| public class PdfReportingService implements ReportingService { | ||
| @Override | ||
| public String generate() { | ||
| return "pdf-report"; | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
...dencies-should-be-resolved/module-a/src/main/java/com/example/modulea/PrimaryCarrier.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.example.modulea; | ||
|
|
||
| import com.example.common.ShippingCarrier; | ||
| import org.springframework.context.annotation.Primary; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Primary | ||
| @Component | ||
| public class PrimaryCarrier implements ShippingCarrier { | ||
| @Override | ||
| public String track(String trackingId) { | ||
| return "primary:" + trackingId; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Quality: junit-platform.properties still documents/enables removed CONCURRENT mode
ScannerIntegrationAbstractTestis now@Execution(ExecutionMode.SAME_THREAD), so no test class inits/scanner-integration-testsruns concurrently, yetjunit-platform.propertiesstill enables parallel execution and its comment explicitly states "Subclasses of ScannerIntegrationAbstractTest are annotated with @execution(CONCURRENT); these properties activate it" — the only two subclasses (AmbiguousDependencyCrossModuleTest, SpringBeansShouldBeAccessibleCrossModuleTest) inherit SAME_THREAD. A maintainer reading the properties file will believe these ITs run in parallel and may "restore" concurrency, re-introducing whatever flakiness this commit removed. Update the comment (and drop the now-inert parallel properties, or note why they are kept) so config and code agree.Align the properties file with the SAME_THREAD annotation and explain why.:
Was this helpful? React with 👍 / 👎