File tree 3 files changed +34
-1
lines changed
sentry/src/main/java/io/sentry
3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
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
+
3
10
## 7.16.0-alpha.1
4
11
5
12
### Features
8
15
9
16
### Fixes
10
17
11
- - Replace setOf with HashSet.add ([ #3801 ] ( https://github.com/getsentry/sentry-java/pull/3801 ) )
12
18
- Cache parsed Dsn ([ #3796 ] ( https://github.com/getsentry/sentry-java/pull/3796 ) )
13
19
- fix invalid profiles when the transaction name is empty ([ #3747 ] ( https://github.com/getsentry/sentry-java/pull/3747 ) )
14
20
- 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) {
217
217
* @param options options the SentryOptions
218
218
* @param globalHubMode the globalHubMode
219
219
*/
220
+ @ SuppressWarnings ({
221
+ "Convert2MethodRef" ,
222
+ "FutureReturnValueIgnored"
223
+ }) // older AGP versions do not support method references
220
224
private static synchronized void init (
221
225
final @ NotNull SentryOptions options , final boolean globalHubMode ) {
222
226
if (isEnabled ()) {
@@ -231,6 +235,18 @@ private static synchronized void init(
231
235
return ;
232
236
}
233
237
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
+
234
250
options .getLogger ().log (SentryLevel .INFO , "GlobalHubMode: '%s'" , String .valueOf (globalHubMode ));
235
251
Sentry .globalHubMode = globalHubMode ;
236
252
Original file line number Diff line number Diff line change @@ -2451,6 +2451,17 @@ public void setEnableScreenTracking(final boolean enableScreenTracking) {
2451
2451
this .enableScreenTracking = enableScreenTracking ;
2452
2452
}
2453
2453
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
+
2454
2465
/** The BeforeSend callback */
2455
2466
public interface BeforeSendCallback {
2456
2467
You can’t perform that action at this time.
0 commit comments