From a5098280b52aec28c71c150e286b5c937767634d Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Tue, 7 Jan 2025 11:38:07 +0100 Subject: [PATCH] Enable `ThreadLocalAccessor` for Spring Boot 3 WebFlux by default (#4023) * Enable ThreadLocalAccessor for Spring Boot 3 WebFlux by default * changelog --- CHANGELOG.md | 6 ++++++ .../spring/boot/jakarta/SentryWebfluxAutoConfiguration.java | 6 +++--- .../boot/jakarta/SentryWebfluxAutoConfigurationTest.kt | 6 ++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a72f38ccae..ed8f5e3a43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Features + +- Enable `ThreadLocalAccessor` for Spring Boot 3 WebFlux by default ([#4023](https://github.com/getsentry/sentry-java/pull/4023)) + ## 8.0.0-rc.3 ### Features diff --git a/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryWebfluxAutoConfiguration.java b/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryWebfluxAutoConfiguration.java index 2bc8bc87ed..468f4b8107 100644 --- a/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryWebfluxAutoConfiguration.java +++ b/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryWebfluxAutoConfiguration.java @@ -91,8 +91,7 @@ public SentryLegacyFilterConfigurationCondition() { @ConditionalOnProperty( name = "sentry.reactive.thread-local-accessor-enabled", - havingValue = "false", - matchIfMissing = true) + havingValue = "false") @SuppressWarnings("UnusedNestedClass") private static class SentryDisableThreadLocalAccessorCondition {} @@ -109,7 +108,8 @@ public SentryThreadLocalAccessorCondition() { @ConditionalOnProperty( name = "sentry.reactive.thread-local-accessor-enabled", - havingValue = "true") + havingValue = "true", + matchIfMissing = true) @SuppressWarnings("UnusedNestedClass") private static class SentryEnableThreadLocalAccessorCondition {} diff --git a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryWebfluxAutoConfigurationTest.kt b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryWebfluxAutoConfigurationTest.kt index f65cc3e108..b4cbaf8631 100644 --- a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryWebfluxAutoConfigurationTest.kt +++ b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryWebfluxAutoConfigurationTest.kt @@ -21,8 +21,8 @@ class SentryWebfluxAutoConfigurationTest { fun `configures sentryWebFilter`() { contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj") .run { - assertThat(it).hasSingleBean(SentryWebFilter::class.java) - assertThat(it).doesNotHaveBean(SentryWebFilterWithThreadLocalAccessor::class.java) + assertThat(it).hasSingleBean(SentryWebFilterWithThreadLocalAccessor::class.java) + assertThat(it).doesNotHaveBean(SentryWebFilter::class.java) } } @@ -63,6 +63,7 @@ class SentryWebfluxAutoConfigurationTest { ) .run { assertThat(it).hasSingleBean(SentryWebFilterWithThreadLocalAccessor::class.java) + assertThat(it).doesNotHaveBean(SentryWebFilter::class.java) } } @@ -75,6 +76,7 @@ class SentryWebfluxAutoConfigurationTest { ) .run { assertThat(it).doesNotHaveBean(SentryWebFilterWithThreadLocalAccessor::class.java) + assertThat(it).hasSingleBean(SentryWebFilter::class.java) } }