File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed
sentry/src/main/java/io/sentry Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 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
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 ) )
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments