File tree Expand file tree Collapse file tree 3 files changed +18
-9
lines changed
main/java/io/sentry/android/core
test/java/io/sentry/android/core/internal/modules Expand file tree Collapse file tree 3 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ static void initializeIntegrationsAndProcessors(
200200 final @ NotNull AppStartMetrics appStartMetrics = AppStartMetrics .getInstance ();
201201
202202 if (options .getModulesLoader () instanceof NoOpModulesLoader ) {
203- options .setModulesLoader (new AssetsModulesLoader (context , options . getLogger () ));
203+ options .setModulesLoader (new AssetsModulesLoader (context , options ));
204204 }
205205 if (options .getDebugMetaLoader () instanceof NoOpDebugMetaLoader ) {
206206 options .setDebugMetaLoader (new AssetsDebugMetaLoader (context , options .getLogger ()));
Original file line number Diff line number Diff line change 11package io .sentry .android .core .internal .modules ;
22
33import android .content .Context ;
4- import io .sentry .ILogger ;
54import io .sentry .SentryLevel ;
5+ import io .sentry .SentryOptions ;
66import io .sentry .android .core .ContextUtils ;
77import io .sentry .internal .modules .ModulesLoader ;
88import java .io .FileNotFoundException ;
@@ -18,13 +18,21 @@ public final class AssetsModulesLoader extends ModulesLoader {
1818
1919 private final @ NotNull Context context ;
2020
21- public AssetsModulesLoader (final @ NotNull Context context , final @ NotNull ILogger logger ) {
22- super (logger );
21+ public AssetsModulesLoader (final @ NotNull Context context , final @ NotNull SentryOptions options ) {
22+ super (options . getLogger () );
2323 this .context = ContextUtils .getApplicationContext (context );
2424
2525 // pre-load modules on a bg thread to avoid doing so on the main thread in case of a crash/error
26- //noinspection Convert2MethodRef
27- new Thread (() -> getOrLoadModules ()).start ();
26+ try {
27+ options
28+ .getExecutorService ()
29+ .submit (
30+ () -> {
31+ getOrLoadModules ();
32+ });
33+ } catch (Throwable e ) {
34+ options .getLogger ().log (SentryLevel .ERROR , "AssetsModulesLoader submit failed" , e );
35+ }
2836 }
2937
3038 @ Override
Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ package io.sentry.android.core.internal.modules
22
33import android.content.Context
44import android.content.res.AssetManager
5- import io.sentry.ILogger
5+ import io.sentry.SentryOptions
6+ import io.sentry.test.ImmediateExecutorService
67import java.io.FileNotFoundException
78import java.nio.charset.Charset
89import kotlin.test.Test
@@ -16,7 +17,7 @@ class AssetsModulesLoaderTest {
1617 class Fixture {
1718 val context = mock<Context >()
1819 val assets = mock<AssetManager >()
19- val logger = mock< ILogger >()
20+ val options = SentryOptions (). apply { executorService = ImmediateExecutorService () }
2021
2122 fun getSut (
2223 fileName : String = "sentry-external-modules.txt",
@@ -31,7 +32,7 @@ class AssetsModulesLoaderTest {
3132 whenever(assets.open(fileName)).thenThrow(FileNotFoundException ())
3233 }
3334 whenever(context.assets).thenReturn(assets)
34- return AssetsModulesLoader (context, logger )
35+ return AssetsModulesLoader (context, options )
3536 }
3637 }
3738
You can’t perform that action at this time.
0 commit comments