Skip to content

Initializing Sentry triggers a StrictMode violation #909

@mshafrir-stripe

Description

@mshafrir-stripe

Platform:

  • Android -> API 23 & 29 emulator,compileSdkVersion/targetSdkVersion are set to 30
  • Java -> If yes, which Java (and sourceCompatibility/targetCompatibility) version?
  • Kotlin -> If yes, which Kotlin (and jvmTarget) version?
  • NDK -> If yes, which NDK/CMake version?
  • React-Native -> If yes, which version?

IDE:

  • Android Studio -> 4.0
  • IntelliJ -> If yes, which version?
  • Other -> If yes, which one?

Build system:

  • Gradle -> 6.5.1
  • Buck -> If yes, which version?
  • Bazel -> If yes, which version?
  • Other -> If yes, which one?

Android Gradle Plugin:

  • Yes -> 4.0.0
  • No

Sentry Android Gradle Plugin:

  • Yes -> 1.7.35
  • No

Proguard/R8:

  • Enabled
  • Disabled

sentry-android installed with:

  • JCenter
  • Bintray
  • Maven Central
  • Manually

The version of sentry-android:
2.2.0


I have the following issue:

Initializing Sentry triggers a StrictMode violation

Steps to reproduce:

  • Enable StrictMode logging in Application subclass
     StrictMode.setThreadPolicy(
         StrictMode.ThreadPolicy.Builder()
             .detectAll()
             .penaltyLog()
             .build()
     )
     StrictMode.setVmPolicy(
         StrictMode.VmPolicy.Builder()
             .detectAll()
             .penaltyLog()
             .build()
     )
    
  • Initialize Sentry automatically
  • Run adb logcat -s StrictMode
  • Launch application

Actual result:

07-07 11:23:32.694 16309 16317 E StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
07-07 11:23:32.694 16309 16317 E StrictMode: java.lang.Throwable: Explicit termination method 'end' not called
07-07 11:23:32.694 16309 16317 E StrictMode: 	at dalvik.system.CloseGuard.open(CloseGuard.java:180)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at java.util.zip.Inflater.<init>(Inflater.java:82)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at com.android.okhttp.okio.GzipSource.<init>(GzipSource.java:62)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at com.android.okhttp.internal.http.HttpEngine.unzip(HttpEngine.java:645)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:827)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:439)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:384)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getHeaders(HttpURLConnectionImpl.java:150)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getHeaderField(HttpURLConnectionImpl.java:194)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getHeaderField(DelegatingHttpsURLConnection.java:190)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getHeaderField(HttpsURLConnectionImpl.java)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at io.sentry.core.transport.HttpTransport.updateRetryAfterLimits(HttpTransport.java:362)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at io.sentry.core.transport.HttpTransport.send(HttpTransport.java:298)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at io.sentry.core.transport.AsyncConnection$SessionSender.flush(AsyncConnection.java:373)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at io.sentry.core.transport.AsyncConnection$SessionSender.run(AsyncConnection.java:341)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
07-07 11:23:32.694 16309 16317 E StrictMode: 	at java.lang.Thread.run(Thread.java:818)

Expected result:

  • No StrictMode violation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions