From df78ae98ebb6164fed6fac4cf63ac20665397cfb Mon Sep 17 00:00:00 2001 From: Sage Maasch Date: Tue, 17 Jun 2025 15:21:57 +0200 Subject: [PATCH 1/7] fix(deps): bump spring boot and spring cloud version up bump spring boot to 3.5.0 bump spring cloud to 2025.0.0 BREAKING CHANGE: it can happen that a misalignment occurs between the version of the junit-platform-launcher provided by gradle and the version of the junit-jupiter-engine provided in the spring dependencies. In this case, gradle is not able to run the tests and throws an error. It's necessary to add testRuntimeOnly 'org.junit.platform:junit-platform-launcher' as a dependency in your build.gradle file then. That takes the version for the unit-platform-launcher from the dependency management. --- sda-commons-dependencies/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sda-commons-dependencies/build.gradle b/sda-commons-dependencies/build.gradle index d7bb012b..dd57c0c5 100644 --- a/sda-commons-dependencies/build.gradle +++ b/sda-commons-dependencies/build.gradle @@ -9,8 +9,8 @@ javaPlatform { ext { bouncycastleVersion = '1.81' logbackContribVersion = '0.1.5' - springBootVersion = '3.4.5' - springCloudVersion = '2024.0.1' + springBootVersion = '3.5.0' + springCloudVersion = '2025.0.0' scalaVersion = '2.13.16' swaggerCoreVersion = '2.2.33' victoolsVersion = '4.38.0' From 354fc924a41d0990cd23a7e0e61ba3457ec3632a Mon Sep 17 00:00:00 2001 From: Sage Maasch Date: Tue, 17 Jun 2025 15:26:16 +0200 Subject: [PATCH 2/7] fix(deps): add junit-platform-launcher in the necessary packages --- sda-commons-asyncapi/build.gradle | 1 + sda-commons-cacertificates/build.gradle | 1 + sda-commons-dependency-check/build.gradle | 1 + sda-commons-starter-mongodb/build.gradle | 1 + 4 files changed, 4 insertions(+) diff --git a/sda-commons-asyncapi/build.gradle b/sda-commons-asyncapi/build.gradle index 76152ff0..19d66350 100644 --- a/sda-commons-asyncapi/build.gradle +++ b/sda-commons-asyncapi/build.gradle @@ -16,4 +16,5 @@ dependencies { api 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml' testImplementation project (':sda-commons-web-testing') + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } diff --git a/sda-commons-cacertificates/build.gradle b/sda-commons-cacertificates/build.gradle index f5999d2e..4bea55bc 100644 --- a/sda-commons-cacertificates/build.gradle +++ b/sda-commons-cacertificates/build.gradle @@ -5,4 +5,5 @@ dependencies { } implementation 'org.yaml:snakeyaml' testImplementation 'org.springframework.boot:spring-boot-starter-test' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } \ No newline at end of file diff --git a/sda-commons-dependency-check/build.gradle b/sda-commons-dependency-check/build.gradle index 4aadfa76..66d8c5df 100644 --- a/sda-commons-dependency-check/build.gradle +++ b/sda-commons-dependency-check/build.gradle @@ -14,6 +14,7 @@ dependencies { api project(":sda-commons-web-testing") testImplementation "io.github.classgraph:classgraph" + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } /** diff --git a/sda-commons-starter-mongodb/build.gradle b/sda-commons-starter-mongodb/build.gradle index 8a5254ef..cf94391d 100644 --- a/sda-commons-starter-mongodb/build.gradle +++ b/sda-commons-starter-mongodb/build.gradle @@ -5,4 +5,5 @@ dependencies { testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation project(":sda-commons-web-testing") testImplementation project(":sda-commons-metadata-context") + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } From adb2b64f8f766507446576a670e10aa45ee7d067 Mon Sep 17 00:00:00 2001 From: Sage Maasch Date: Tue, 17 Jun 2025 15:49:18 +0200 Subject: [PATCH 3/7] fix: change code that was marked as deprecated and for removal --- .../boot/kafka/KafkaHealthIndicatorIntegrationTest.java | 4 ++-- .../commons/spring/boot/mongodb/SdaMongoDbConfiguration.java | 2 +- .../boot/web/auth/opa/OpaRestTemplateConfiguration.java | 2 +- .../boot/web/security/handler/ValidationExceptionHandler.java | 2 +- .../spring/boot/web/monitoring/testing/TracedFeignClient.java | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sda-commons-starter-kafka/src/test/java/org/sdase/commons/spring/boot/kafka/KafkaHealthIndicatorIntegrationTest.java b/sda-commons-starter-kafka/src/test/java/org/sdase/commons/spring/boot/kafka/KafkaHealthIndicatorIntegrationTest.java index 0a180426..c570391f 100644 --- a/sda-commons-starter-kafka/src/test/java/org/sdase/commons/spring/boot/kafka/KafkaHealthIndicatorIntegrationTest.java +++ b/sda-commons-starter-kafka/src/test/java/org/sdase/commons/spring/boot/kafka/KafkaHealthIndicatorIntegrationTest.java @@ -20,7 +20,6 @@ import org.springframework.boot.actuate.health.Health; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.server.LocalManagementPort; import org.springframework.http.ResponseEntity; @@ -28,6 +27,7 @@ import org.springframework.kafka.listener.MessageListenerContainer; import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; @SetSystemProperty(key = "management.health.kafka.enabled", value = "true") @SetSystemProperty(key = "management.health.kafka.timeout", value = "8s") @@ -50,7 +50,7 @@ class KafkaHealthIndicatorIntegrationTest { @Autowired private TestRestTemplate client; - @SpyBean private KafkaHealthIndicator kafkaHealthIndicator; + @MockitoSpyBean private KafkaHealthIndicator kafkaHealthIndicator; @Autowired private KafkaListenerEndpointRegistry kafkaListenerEndpointRegistry; diff --git a/sda-commons-starter-mongodb/src/main/java/org/sdase/commons/spring/boot/mongodb/SdaMongoDbConfiguration.java b/sda-commons-starter-mongodb/src/main/java/org/sdase/commons/spring/boot/mongodb/SdaMongoDbConfiguration.java index 92971951..16ff1cf7 100644 --- a/sda-commons-starter-mongodb/src/main/java/org/sdase/commons/spring/boot/mongodb/SdaMongoDbConfiguration.java +++ b/sda-commons-starter-mongodb/src/main/java/org/sdase/commons/spring/boot/mongodb/SdaMongoDbConfiguration.java @@ -71,7 +71,7 @@ public void initIndicesAfterStartup() { .resolveIndexFor(it.getType()) .forEach( indexDefinition -> { - indexOps.ensureIndex(indexDefinition); + indexOps.createIndex(indexDefinition); LOG.info("Ensured index '{}'", indexDefinition.getIndexOptions()); }); }); diff --git a/sda-commons-starter-web/src/main/java/org/sdase/commons/spring/boot/web/auth/opa/OpaRestTemplateConfiguration.java b/sda-commons-starter-web/src/main/java/org/sdase/commons/spring/boot/web/auth/opa/OpaRestTemplateConfiguration.java index eb33049e..a6cb0074 100644 --- a/sda-commons-starter-web/src/main/java/org/sdase/commons/spring/boot/web/auth/opa/OpaRestTemplateConfiguration.java +++ b/sda-commons-starter-web/src/main/java/org/sdase/commons/spring/boot/web/auth/opa/OpaRestTemplateConfiguration.java @@ -34,6 +34,6 @@ public OpaRestTemplateConfiguration( @Bean("opaRestTemplate") public RestTemplate opaRestTemplate(RestTemplateBuilder builder) { - return builder.setConnectTimeout(connectionTimeout).setReadTimeout(timeout).build(); + return builder.connectTimeout(connectionTimeout).readTimeout(timeout).build(); } } diff --git a/sda-commons-starter-web/src/main/java/org/sdase/commons/spring/boot/web/security/handler/ValidationExceptionHandler.java b/sda-commons-starter-web/src/main/java/org/sdase/commons/spring/boot/web/security/handler/ValidationExceptionHandler.java index 82d7d7e8..4d4e1d4f 100644 --- a/sda-commons-starter-web/src/main/java/org/sdase/commons/spring/boot/web/security/handler/ValidationExceptionHandler.java +++ b/sda-commons-starter-web/src/main/java/org/sdase/commons/spring/boot/web/security/handler/ValidationExceptionHandler.java @@ -76,7 +76,7 @@ public ResponseEntity validationErrorJakartaAnnotation( // If MessageSourceResolvable is instance of FieldError, then add additional information. List invalidParams = - ex.getAllValidationResults().stream() + ex.getParameterValidationResults().stream() .flatMap( parameterValidationResult -> parameterValidationResult.getResolvableErrors().stream()) diff --git a/sda-commons-starter-web/src/test/java/org/sdase/commons/spring/boot/web/monitoring/testing/TracedFeignClient.java b/sda-commons-starter-web/src/test/java/org/sdase/commons/spring/boot/web/monitoring/testing/TracedFeignClient.java index 97e615f2..44a84d97 100644 --- a/sda-commons-starter-web/src/test/java/org/sdase/commons/spring/boot/web/monitoring/testing/TracedFeignClient.java +++ b/sda-commons-starter-web/src/test/java/org/sdase/commons/spring/boot/web/monitoring/testing/TracedFeignClient.java @@ -9,7 +9,7 @@ import static jakarta.ws.rs.core.MediaType.TEXT_PLAIN; -import feign.jaxrs.JakartaContract; +import feign.jaxrs3.JAXRS3Contract; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; @@ -18,7 +18,7 @@ @FeignClient( value = "testClient", url = "${test.tracing.client.base.url}", - configuration = JakartaContract.class) + configuration = JAXRS3Contract.class) public interface TracedFeignClient { @GET From 252bb2fe9b14bac772eeb7ebdd5305d0a9d4ad99 Mon Sep 17 00:00:00 2001 From: Sage Maasch Date: Tue, 17 Jun 2025 15:54:39 +0200 Subject: [PATCH 4/7] feat: remove code that was marked as deprecated and for removal BREAKING CHANGE: removed feign.jaxrs.JakartaContract from sda-commons-starter-web removed kafkaDltTemplate Bean from sda-commons-starter-kafka --- .../kafka/SdaKafkaProducerConfiguration.java | 17 -------------- .../java/feign/jaxrs/JakartaContract.java | 23 ------------------- 2 files changed, 40 deletions(-) delete mode 100644 sda-commons-starter-web/src/main/java/feign/jaxrs/JakartaContract.java diff --git a/sda-commons-starter-kafka/src/main/java/org/sdase/commons/spring/boot/kafka/SdaKafkaProducerConfiguration.java b/sda-commons-starter-kafka/src/main/java/org/sdase/commons/spring/boot/kafka/SdaKafkaProducerConfiguration.java index e8c1c8ae..fe4decb9 100644 --- a/sda-commons-starter-kafka/src/main/java/org/sdase/commons/spring/boot/kafka/SdaKafkaProducerConfiguration.java +++ b/sda-commons-starter-kafka/src/main/java/org/sdase/commons/spring/boot/kafka/SdaKafkaProducerConfiguration.java @@ -85,21 +85,4 @@ public SdaKafkaProducerConfiguration(ObjectMapper objectMapper) { return new KafkaTemplate<>(producerFactoryByte, props); } - - /** - * Keep Bean to not introduce breaking changes superseded by kafkaByteArrayDltTemplate should be - * removed with next major update - * - * @deprecated (uses default producerFactory which can have side effects on other templates) - */ - @Deprecated(since = "4.1.0", forRemoval = true) - @Bean - @SuppressWarnings("java:S1452") - public KafkaTemplate kafkaDltTemplate( - ProducerFactory producerFactory) { - Map props = new HashMap<>(commonProperties); - props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); - props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class); - return new KafkaTemplate<>(producerFactory, props); - } } diff --git a/sda-commons-starter-web/src/main/java/feign/jaxrs/JakartaContract.java b/sda-commons-starter-web/src/main/java/feign/jaxrs/JakartaContract.java deleted file mode 100644 index eb98245c..00000000 --- a/sda-commons-starter-web/src/main/java/feign/jaxrs/JakartaContract.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2022- SDA SE Open Industry Solutions (https://www.sda.se) - * - * Use of this source code is governed by an MIT-style - * license that can be found in the LICENSE file or at - * https://opensource.org/licenses/MIT. - */ -package feign.jaxrs; - -import feign.jaxrs3.JAXRS3Contract; - -/** - * Due to some Maven - * Magic that prevents loading the dependency with gradle, we added this deprecated class - * temporarily here. - * - * @deprecated use {@link JAXRS3Contract} instead, {@code JakartaContract} will be removed in the - * next major of SDA Spring Boot Commons! - */ -@Deprecated(forRemoval = true) -@SuppressWarnings({"java:S110", "java:S1133", "DeprecatedIsStillUsed"}) -public class JakartaContract extends JAXRS3Contract {} From 49f4639f20b642fc922086a7f121e15a1c2a476c Mon Sep 17 00:00:00 2001 From: Sage Maasch Date: Tue, 17 Jun 2025 16:53:14 +0200 Subject: [PATCH 5/7] test(kafka): fix KafkaHealthIndicatorIntegrationTest --- .../boot/kafka/KafkaHealthIndicatorIntegrationTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sda-commons-starter-kafka/src/test/java/org/sdase/commons/spring/boot/kafka/KafkaHealthIndicatorIntegrationTest.java b/sda-commons-starter-kafka/src/test/java/org/sdase/commons/spring/boot/kafka/KafkaHealthIndicatorIntegrationTest.java index c570391f..b41f3ff5 100644 --- a/sda-commons-starter-kafka/src/test/java/org/sdase/commons/spring/boot/kafka/KafkaHealthIndicatorIntegrationTest.java +++ b/sda-commons-starter-kafka/src/test/java/org/sdase/commons/spring/boot/kafka/KafkaHealthIndicatorIntegrationTest.java @@ -20,6 +20,7 @@ import org.springframework.boot.actuate.health.Health; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.server.LocalManagementPort; import org.springframework.http.ResponseEntity; @@ -28,6 +29,7 @@ import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; @SetSystemProperty(key = "management.health.kafka.enabled", value = "true") @SetSystemProperty(key = "management.health.kafka.timeout", value = "8s") @@ -50,7 +52,10 @@ class KafkaHealthIndicatorIntegrationTest { @Autowired private TestRestTemplate client; - @MockitoSpyBean private KafkaHealthIndicator kafkaHealthIndicator; + @SuppressWarnings("removal") + //The MockitoSpyBean that should replace the SpyBean doesn't work exactly the same. See https://github.com/spring-projects/spring-framework/issues/33934. + //It has to be further investigated, what steps are necessary to remove this deprecated reference. + @SpyBean private KafkaHealthIndicator kafkaHealthIndicator; @Autowired private KafkaListenerEndpointRegistry kafkaListenerEndpointRegistry; From 0734fcd183d8528f56b8c8101366192e5ef3a487 Mon Sep 17 00:00:00 2001 From: Sage Maasch Date: Tue, 17 Jun 2025 16:59:00 +0200 Subject: [PATCH 6/7] refactor: apply spotless --- .../kafka/KafkaHealthIndicatorIntegrationTest.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sda-commons-starter-kafka/src/test/java/org/sdase/commons/spring/boot/kafka/KafkaHealthIndicatorIntegrationTest.java b/sda-commons-starter-kafka/src/test/java/org/sdase/commons/spring/boot/kafka/KafkaHealthIndicatorIntegrationTest.java index b41f3ff5..98c3cfda 100644 --- a/sda-commons-starter-kafka/src/test/java/org/sdase/commons/spring/boot/kafka/KafkaHealthIndicatorIntegrationTest.java +++ b/sda-commons-starter-kafka/src/test/java/org/sdase/commons/spring/boot/kafka/KafkaHealthIndicatorIntegrationTest.java @@ -28,8 +28,6 @@ import org.springframework.kafka.listener.MessageListenerContainer; import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; -import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; @SetSystemProperty(key = "management.health.kafka.enabled", value = "true") @SetSystemProperty(key = "management.health.kafka.timeout", value = "8s") @@ -53,9 +51,12 @@ class KafkaHealthIndicatorIntegrationTest { @Autowired private TestRestTemplate client; @SuppressWarnings("removal") - //The MockitoSpyBean that should replace the SpyBean doesn't work exactly the same. See https://github.com/spring-projects/spring-framework/issues/33934. - //It has to be further investigated, what steps are necessary to remove this deprecated reference. - @SpyBean private KafkaHealthIndicator kafkaHealthIndicator; + // The MockitoSpyBean that should replace the SpyBean doesn't work exactly the same. See + // https://github.com/spring-projects/spring-framework/issues/33934. + // It has to be further investigated, what steps are necessary to remove this deprecated + // reference. + @SpyBean + private KafkaHealthIndicator kafkaHealthIndicator; @Autowired private KafkaListenerEndpointRegistry kafkaListenerEndpointRegistry; From 304e8eced4fc4dc1be85163bcd3ecf773a214421 Mon Sep 17 00:00:00 2001 From: Sage Maasch Date: Wed, 18 Jun 2025 10:18:01 +0200 Subject: [PATCH 7/7] docs: add migration guide and extra description for junit launcher --- docs/index.md | 5 +++++ docs/migration-4-to-5.md | 20 ++++++++++++++++++++ mkdocs.yaml | 5 ++++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 docs/migration-4-to-5.md diff --git a/docs/index.md b/docs/index.md index 3afceda6..563b3a84 100644 --- a/docs/index.md +++ b/docs/index.md @@ -48,6 +48,11 @@ dependencies { } ``` +With gradle 9 it will be mandatory to define a launcher to run your tests with gradle. SDA Spring Boot Commons uses junit. That's why it is recommended adding the following dependency to your defined dependencies: +``` +testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +``` + Artifacts of SDA Spring Boot Commons are available [at Maven Central](https://search.maven.org/search?q=g:org.sdase.commons.spring.boot) since release [0.11.2](https://github.com/SDA-SE/sda-spring-boot-commons/releases/tag/0.11.2). diff --git a/docs/migration-4-to-5.md b/docs/migration-4-to-5.md new file mode 100644 index 00000000..a57f659a --- /dev/null +++ b/docs/migration-4-to-5.md @@ -0,0 +1,20 @@ +# Migration Guide for Upgrading from 4.x.x to 5.x.x + +SDA Spring Boot Commons 5 updates + +- Spring Boot from 3.4.x to 3.5.x and +- Spring Cloud from 2024.x.x to 2025.x.x. + +This comes with some breaking changes introduced by Spring and some possible ones from SDA Spring Boot Commons as +well. +Other libraries are upgraded or replaced as well. + +In addition to this migration guide, the [official release notes of Spring Boot](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.5-Release-Notes) +and [Spring Cloud](https://github.com/spring-cloud/spring-cloud-release/wiki/Spring-Cloud-2025.0-Release-Notes) should be consulted. + +Summary of noticeable changes: + +- It can happen that a misalignment occurs between the version of the junit-platform-launcher found by gradle and the version of the junit-jupiter-engine provided in the spring dependencies. In this case, gradle is not able to run the tests and throws an error. It's necessary to add testRuntimeOnly 'org.junit.platform:junit-platform-launcher' as a dependency in your build.gradle file then. That takes the version for the junit-platform-launcher from the dependency management. In general, it should be considered to add this dependency in your build.gradle file. With gradle 9 this dependency will be [mandatory](github.com/gradle/gradle/issues/26114). +- The provided and deprecated feign.jaxrs.JakartaContract got removed from the sda-commons-starter-web package. +- The provided and deprecated kafkaDltTemplate Bean got removed from the sda-commons-starter-kafka package. +- The Spring TestRestTemplate now uses the same redirect rules as the regular RestTemplate. Additionally, the HttpOption.ENABLE_REDIRECTS option has been deprecated. \ No newline at end of file diff --git a/mkdocs.yaml b/mkdocs.yaml index ab56f5d9..c48ae7ce 100644 --- a/mkdocs.yaml +++ b/mkdocs.yaml @@ -10,7 +10,6 @@ site_name: sda-spring-boot-commons nav: - Overview: index.md - - Migrate to v3: migration-2-to-3.md - Starter Web: starter-web.md - Starter MongoDB: starter-mongodb.md - Starter Kafka: starter-kafka.md @@ -20,6 +19,10 @@ nav: - Cloud Events: cloudevents.md - Metadata Context: metadata-context.md - Testing: web-testing.md + - Migration: + - Migrate to v3: migration-2-to-3.md + - Migrate to v4: migration-3-to-4.md + - Migrate to v5: migration-4-to-5.md # Always include the techdocs-core plugin, otherwise it's not possible to # display the documentation in Backstage. We don't support other plugins