Skip to content

Commit b402f00

Browse files
committed
GH-77 - Upgrade to Spring Boot 3.0.
Adapt to API changes in Micrometer and Spring Boot's test context loader API now exposing a checked ContextLoadException to signal failures during ApplicationContext bootstraps.
1 parent 065db76 commit b402f00

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3434
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
3535
<spring-asciidoctor-backends.version>0.0.4-SNAPSHOT</spring-asciidoctor-backends.version>
36-
<spring-boot.version>3.0.0-RC1</spring-boot.version>
36+
<spring-boot.version>3.0.0</spring-boot.version>
3737

3838
</properties>
3939

spring-modulith-observability/src/main/java/org/springframework/modulith/observability/ModuleEntryInterceptor.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.modulith.observability;
1717

18-
import io.micrometer.tracing.BaggageInScope;
18+
import io.micrometer.tracing.Baggage;
1919
import io.micrometer.tracing.Span;
2020
import io.micrometer.tracing.Tracer;
2121
import io.micrometer.tracing.Tracer.SpanInScope;
@@ -59,7 +59,7 @@ public Object invoke(MethodInvocation invocation) throws Throwable {
5959

6060
if (currentSpan != null) {
6161

62-
BaggageInScope currentBaggage = tracer.getBaggage(ModuleTracingBeanPostProcessor.MODULE_BAGGAGE_KEY);
62+
Baggage currentBaggage = tracer.getBaggage(ModuleTracingBeanPostProcessor.MODULE_BAGGAGE_KEY);
6363

6464
if (currentBaggage != null && moduleName.equals(currentBaggage.get())) {
6565
return invocation.proceed();
@@ -76,10 +76,9 @@ public Object invoke(MethodInvocation invocation) throws Throwable {
7676
.tag(ModuleTracingBeanPostProcessor.MODULE_BAGGAGE_KEY, moduleName)
7777
.start();
7878

79-
try (
80-
SpanInScope ws = tracer.withSpan(span); //
81-
BaggageInScope baggage = tracer.createBaggage(ModuleTracingBeanPostProcessor.MODULE_BAGGAGE_KEY, moduleName); //
82-
) {
79+
tracer.createBaggage(ModuleTracingBeanPostProcessor.MODULE_BAGGAGE_KEY, moduleName);
80+
81+
try (SpanInScope ws = tracer.withSpan(span)) {
8382

8483
return invocation.proceed();
8584

spring-modulith-test/src/main/java/org/springframework/modulith/test/TestUtils.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.context.ConfigurableApplicationContext;
2626
import org.springframework.test.context.BootstrapContext;
2727
import org.springframework.test.context.CacheAwareContextLoaderDelegate;
28+
import org.springframework.test.context.ContextLoadException;
2829
import org.springframework.test.context.MergedContextConfiguration;
2930
import org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate;
3031
import org.springframework.test.context.support.DefaultBootstrapContext;
@@ -52,13 +53,10 @@ public static void assertDependencyMissing(Class<?> testClass, Class<?> expected
5253

5354
return (ConfigurableApplicationContext) loader.loadContext(configuration);
5455

55-
} catch (Exception e) {
56-
57-
if (e instanceof RuntimeException) {
58-
throw (RuntimeException) e;
59-
}
60-
61-
throw new RuntimeException(e);
56+
} catch (ContextLoadException o_O) {
57+
throw asRuntimeException(o_O.getCause());
58+
} catch (Exception o_O) {
59+
throw asRuntimeException(o_O);
6260
}
6361
});
6462

@@ -70,4 +68,8 @@ public static void assertDependencyMissing(Class<?> testClass, Class<?> expected
7068
});
7169
});
7270
}
71+
72+
private static RuntimeException asRuntimeException(Throwable o_O) {
73+
return o_O instanceof RuntimeException ? (RuntimeException) o_O : new RuntimeException(o_O);
74+
}
7375
}

0 commit comments

Comments
 (0)