Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
use option's executor instead of a new thread to load fields
  • Loading branch information
stefanosiano committed Oct 17, 2024
commit 8482a294986199f5d687a60a0801865c052e975e
16 changes: 14 additions & 2 deletions sentry/src/main/java/io/sentry/Sentry.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@ public static void init(final @NotNull SentryOptions options) {
* @param options options the SentryOptions
* @param globalHubMode the globalHubMode
*/
@SuppressWarnings("Convert2MethodRef") // older AGP versions do not support method references
@SuppressWarnings({
"Convert2MethodRef",
"FutureReturnValueIgnored"
}) // older AGP versions do not support method references
private static synchronized void init(
final @NotNull SentryOptions options, final boolean globalHubMode) {
if (isEnabled()) {
Expand All @@ -233,7 +236,16 @@ private static synchronized void init(
}

// load lazy fields of the options in a separate thread
new Thread(() -> options.loadLazyFields()).start();
try {
options.getExecutorService().submit(() -> options.loadLazyFields());
} catch (RejectedExecutionException e) {
options
.getLogger()
.log(
SentryLevel.DEBUG,
"Failed to call the executor. Lazy fields will not be loaded. Did you call Sentry.close()?",
e);
}

options.getLogger().log(SentryLevel.INFO, "GlobalHubMode: '%s'", String.valueOf(globalHubMode));
Sentry.globalHubMode = globalHubMode;
Expand Down