diff --git a/CHANGELOG.md b/CHANGELOG.md index 840ecdbbbb..52517b2d66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Added `enableTraceIdGeneration` to the AndroidOptions. This allows Hybrid SDKs to "freeze" and control the trace and connect errors on different layers of the application ([4188](https://github.com/getsentry/sentry-java/pull/4188)) - Move to a single NetworkCallback listener to reduce number of IPC calls on Android ([#4164](https://github.com/getsentry/sentry-java/pull/4164)) - Add GraphQL Apollo Kotlin 4 integration ([#4166](https://github.com/getsentry/sentry-java/pull/4166)) +- Add constructor to JUL `SentryHandler` for disabling external config ([#4208](https://github.com/getsentry/sentry-java/pull/4208)) ### Fixes diff --git a/sentry-jul/api/sentry-jul.api b/sentry-jul/api/sentry-jul.api index 91e126ece7..f07908e333 100644 --- a/sentry-jul/api/sentry-jul.api +++ b/sentry-jul/api/sentry-jul.api @@ -8,6 +8,7 @@ public class io/sentry/jul/SentryHandler : java/util/logging/Handler { public static final field THREAD_ID Ljava/lang/String; public fun ()V public fun (Lio/sentry/SentryOptions;)V + public fun (Lio/sentry/SentryOptions;Z)V public fun close ()V public fun flush ()V public fun getMinimumBreadcrumbLevel ()Ljava/util/logging/Level; diff --git a/sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java b/sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java index d6afd514e6..5d6bb6d922 100644 --- a/sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java +++ b/sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java @@ -51,7 +51,7 @@ public class SentryHandler extends Handler { /** Creates an instance of SentryHandler. */ public SentryHandler() { - this(new SentryOptions(), true); + this(new SentryOptions()); } /** @@ -60,17 +60,32 @@ public SentryHandler() { * @param options the SentryOptions */ public SentryHandler(final @NotNull SentryOptions options) { - this(options, true); + this(options, true, true); + } + + /** + * Creates an instance of SentryHandler. + * + * @param options the SentryOptions + * @param enableExternalConfiguration whether external options like sentry.properties and ENV vars + * should be parsed + */ + public SentryHandler( + final @NotNull SentryOptions options, final boolean enableExternalConfiguration) { + this(options, true, enableExternalConfiguration); } /** Creates an instance of SentryHandler. */ @TestOnly - SentryHandler(final @NotNull SentryOptions options, final boolean configureFromLogManager) { + SentryHandler( + final @NotNull SentryOptions options, + final boolean configureFromLogManager, + final boolean enableExternalConfiguration) { setFilter(new DropSentryFilter()); if (configureFromLogManager) { retrieveProperties(); } - options.setEnableExternalConfiguration(true); + options.setEnableExternalConfiguration(enableExternalConfiguration); options.setInitPriority(InitPriority.LOWEST); options.setSdkVersion(createSdkVersion(options)); Sentry.init(options); diff --git a/sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt b/sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt index 5b7048884d..371c6c2f50 100644 --- a/sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt +++ b/sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt @@ -36,7 +36,7 @@ class SentryHandlerTest { options.setTransportFactory { _, _ -> transport } contextTags?.forEach { options.addContextTag(it) } logger = Logger.getLogger("jul.SentryHandlerTest") - handler = SentryHandler(options, configureWithLogManager) + handler = SentryHandler(options, configureWithLogManager, true) handler.setMinimumBreadcrumbLevel(minimumBreadcrumbLevel) handler.setMinimumEventLevel(minimumEventLevel) handler.level = Level.ALL