Skip to content

Commit 5dda9c3

Browse files
Merge branch 'main' into kw/test/extend-critical-tests-matrix
2 parents a99c02f + 4988d5b commit 5dda9c3

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- Load lazy fields on init in the background ([#3803](https://github.com/getsentry/sentry-java/pull/3803))
8+
- Replace setOf with HashSet.add ([#3801](https://github.com/getsentry/sentry-java/pull/3801))
9+
310
## 7.16.0-alpha.1
411

512
### Features
@@ -8,7 +15,6 @@
815

916
### Fixes
1017

11-
- Replace setOf with HashSet.add ([#3801](https://github.com/getsentry/sentry-java/pull/3801))
1218
- Cache parsed Dsn ([#3796](https://github.com/getsentry/sentry-java/pull/3796))
1319
- fix invalid profiles when the transaction name is empty ([#3747](https://github.com/getsentry/sentry-java/pull/3747))
1420
- Deprecate `enableTracing` option ([#3777](https://github.com/getsentry/sentry-java/pull/3777))

sentry/src/main/java/io/sentry/Sentry.java

+16
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ public static void init(final @NotNull SentryOptions options) {
217217
* @param options options the SentryOptions
218218
* @param globalHubMode the globalHubMode
219219
*/
220+
@SuppressWarnings({
221+
"Convert2MethodRef",
222+
"FutureReturnValueIgnored"
223+
}) // older AGP versions do not support method references
220224
private static synchronized void init(
221225
final @NotNull SentryOptions options, final boolean globalHubMode) {
222226
if (isEnabled()) {
@@ -231,6 +235,18 @@ private static synchronized void init(
231235
return;
232236
}
233237

238+
// load lazy fields of the options in a separate thread
239+
try {
240+
options.getExecutorService().submit(() -> options.loadLazyFields());
241+
} catch (RejectedExecutionException e) {
242+
options
243+
.getLogger()
244+
.log(
245+
SentryLevel.DEBUG,
246+
"Failed to call the executor. Lazy fields will not be loaded. Did you call Sentry.close()?",
247+
e);
248+
}
249+
234250
options.getLogger().log(SentryLevel.INFO, "GlobalHubMode: '%s'", String.valueOf(globalHubMode));
235251
Sentry.globalHubMode = globalHubMode;
236252

sentry/src/main/java/io/sentry/SentryOptions.java

+11
Original file line numberDiff line numberDiff line change
@@ -2451,6 +2451,17 @@ public void setEnableScreenTracking(final boolean enableScreenTracking) {
24512451
this.enableScreenTracking = enableScreenTracking;
24522452
}
24532453

2454+
/**
2455+
* Load the lazy fields. Useful to load in the background, so that results are already cached. DO
2456+
* NOT CALL THIS METHOD ON THE MAIN THREAD.
2457+
*/
2458+
void loadLazyFields() {
2459+
getSerializer();
2460+
getParsedDsn();
2461+
getEnvelopeReader();
2462+
getDateProvider();
2463+
}
2464+
24542465
/** The BeforeSend callback */
24552466
public interface BeforeSendCallback {
24562467

0 commit comments

Comments
 (0)