Skip to content

Commit cde02ad

Browse files
authored
Add constructor to JUL SentryHandler for disabling external config (#4208)
* Add ctor to JUL for disabling external config * changelog
1 parent 7d08e30 commit cde02ad

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- 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))
1111
- Move to a single NetworkCallback listener to reduce number of IPC calls on Android ([#4164](https://github.com/getsentry/sentry-java/pull/4164))
1212
- Add GraphQL Apollo Kotlin 4 integration ([#4166](https://github.com/getsentry/sentry-java/pull/4166))
13+
- Add constructor to JUL `SentryHandler` for disabling external config ([#4208](https://github.com/getsentry/sentry-java/pull/4208))
1314

1415
### Fixes
1516

sentry-jul/api/sentry-jul.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class io/sentry/jul/SentryHandler : java/util/logging/Handler {
88
public static final field THREAD_ID Ljava/lang/String;
99
public fun <init> ()V
1010
public fun <init> (Lio/sentry/SentryOptions;)V
11+
public fun <init> (Lio/sentry/SentryOptions;Z)V
1112
public fun close ()V
1213
public fun flush ()V
1314
public fun getMinimumBreadcrumbLevel ()Ljava/util/logging/Level;

sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class SentryHandler extends Handler {
5151

5252
/** Creates an instance of SentryHandler. */
5353
public SentryHandler() {
54-
this(new SentryOptions(), true);
54+
this(new SentryOptions());
5555
}
5656

5757
/**
@@ -60,17 +60,32 @@ public SentryHandler() {
6060
* @param options the SentryOptions
6161
*/
6262
public SentryHandler(final @NotNull SentryOptions options) {
63-
this(options, true);
63+
this(options, true, true);
64+
}
65+
66+
/**
67+
* Creates an instance of SentryHandler.
68+
*
69+
* @param options the SentryOptions
70+
* @param enableExternalConfiguration whether external options like sentry.properties and ENV vars
71+
* should be parsed
72+
*/
73+
public SentryHandler(
74+
final @NotNull SentryOptions options, final boolean enableExternalConfiguration) {
75+
this(options, true, enableExternalConfiguration);
6476
}
6577

6678
/** Creates an instance of SentryHandler. */
6779
@TestOnly
68-
SentryHandler(final @NotNull SentryOptions options, final boolean configureFromLogManager) {
80+
SentryHandler(
81+
final @NotNull SentryOptions options,
82+
final boolean configureFromLogManager,
83+
final boolean enableExternalConfiguration) {
6984
setFilter(new DropSentryFilter());
7085
if (configureFromLogManager) {
7186
retrieveProperties();
7287
}
73-
options.setEnableExternalConfiguration(true);
88+
options.setEnableExternalConfiguration(enableExternalConfiguration);
7489
options.setInitPriority(InitPriority.LOWEST);
7590
options.setSdkVersion(createSdkVersion(options));
7691
Sentry.init(options);

sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SentryHandlerTest {
3636
options.setTransportFactory { _, _ -> transport }
3737
contextTags?.forEach { options.addContextTag(it) }
3838
logger = Logger.getLogger("jul.SentryHandlerTest")
39-
handler = SentryHandler(options, configureWithLogManager)
39+
handler = SentryHandler(options, configureWithLogManager, true)
4040
handler.setMinimumBreadcrumbLevel(minimumBreadcrumbLevel)
4141
handler.setMinimumEventLevel(minimumEventLevel)
4242
handler.level = Level.ALL

0 commit comments

Comments
 (0)