diff options
author | Jacek Poreda <jacek.poreda@sonarsource.com> | 2024-09-04 10:25:12 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-09-04 20:03:11 +0000 |
commit | a4e8edf67e1ea2aba973a88162d2837dad0a4831 (patch) | |
tree | 79bdc7485f6f1a59d4ab0d55ed2112fc8edd130c | |
parent | 26138bab7d728e4560a9803d784b366704f18f9a (diff) | |
download | sonarqube-a4e8edf67e1ea2aba973a88162d2837dad0a4831.tar.gz sonarqube-a4e8edf67e1ea2aba973a88162d2837dad0a4831.zip |
[NO-JIRA] Fix bean naming in API V2 + enable failing fast in case same bean names appears
3 files changed, 7 insertions, 2 deletions
diff --git a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/config/PlatformLevel4WebConfig.java b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/config/PlatformLevel4WebConfig.java index 87ef131bb29..3bf8b16bf0b 100644 --- a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/config/PlatformLevel4WebConfig.java +++ b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/config/PlatformLevel4WebConfig.java @@ -89,6 +89,7 @@ import org.sonar.server.v2.common.DeprecatedHandler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.Primary; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; @Configuration @@ -152,7 +153,8 @@ public class PlatformLevel4WebConfig { return new DefaultRuleController(userSession, ruleService, ruleRestResponseGenerator); } - @Bean + @Primary + @Bean("org.sonar.server.v2.config.PlatformLevel4WebConfig.requestMappingHandlerMapping") public RequestMappingHandlerMapping requestMappingHandlerMapping(UserSession userSession) { RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping(); handlerMapping.setInterceptors(new DeprecatedHandler(userSession)); diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/ApiV2Servlet.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/ApiV2Servlet.java index 8d1d7d22a19..13bce63f780 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/ApiV2Servlet.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/ApiV2Servlet.java @@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletResponse; import org.sonar.server.platform.platformlevel.PlatformLevel; import org.sonar.server.v2.config.PlatformLevel4WebConfig; import org.sonar.server.v2.config.SafeModeWebConfig; +import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.servlet.DispatcherServlet; @@ -88,6 +89,8 @@ public class ApiV2Servlet implements Servlet { private DispatcherServlet initDispatcherServlet(PlatformLevel platformLevel, Class<?> configClass) { AnnotationConfigWebApplicationContext springMvcContext = new AnnotationConfigWebApplicationContext(); + springMvcContext.setBeanNameGenerator(FullyQualifiedAnnotationBeanNameGenerator.INSTANCE); + springMvcContext.setAllowBeanDefinitionOverriding(false); springMvcContext.setParent(platformLevel.getContainer().context()); springMvcContext.register(configClass); if (PlatformLevel4WebConfig.class.equals(configClass)) { diff --git a/sonar-application/build.gradle b/sonar-application/build.gradle index f2da57e7290..ee484a67c46 100644 --- a/sonar-application/build.gradle +++ b/sonar-application/build.gradle @@ -339,7 +339,7 @@ task zip(type: Zip, dependsOn: [configurations.compileClasspath]) { zip { mustRunAfter cyclonedxBom doLast { - def minLength = 340000000 + def minLength = 342000000 def maxLength = 750000000 def length = archiveFile.get().asFile.length() |