Closed
Description
[REQUIRED] Please fill in the following fields:
- Pre-built SDK from the website or open-source from this repo: prebuilt
- Firebase C++ SDK version: 8.11.0
- Problematic Firebase Component: Messaging
- Other Firebase Components in use: none
- Platform you are using the C++ SDK on: Mac
- Platform you are targeting: Android
[REQUIRED] Please describe the issue here:
- enable strict mode
- shows that closeable is leaked here https://github.com/firebase/firebase-cpp-sdk/blob/v9.0.0/messaging/src/android/java/com/google/firebase/messaging/cpp/RegistrationIntentService.java#L63
2022-05-26 10:43:36.813 9571-9584/? D/StrictMode: StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:1877)
at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:286)
at sun.nio.ch.FileChannelImpl.finalize(FileChannelImpl.java:175)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:289)
at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:276)
at java.lang.Daemons$Daemon.run(Daemons.java:137)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.Throwable: Explicit termination method 'close' not called
at dalvik.system.CloseGuard.open(CloseGuard.java:237)
at sun.nio.ch.FileChannelImpl.<init>(FileChannelImpl.java:110)
at sun.nio.ch.FileChannelImpl.open(FileChannelImpl.java:128)
at java.io.FileOutputStream.getChannel(FileOutputStream.java:469)
at com.google.firebase.messaging.cpp.RegistrationIntentService.writeTokenToInternalStorage(SourceFile:6)
at com.google.firebase.messaging.cpp.RegistrationIntentService.onHandleIntent(SourceFile:3)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:78)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.os.HandlerThread.run(HandlerThread.java:67)
Steps to reproduce:
- Android project using Firebase Messaging
- enable strict mode
StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder()
.detectActivityLeaks()
.detectLeakedClosableObjects()
.penaltyLog()
.build())
- check logcat for
D/StrictMode
logs
100% reproduce.
Sample project that reproduces the bug:
- Use https://github.com/firebase/quickstart-android/tree/master/messaging
- go to file https://github.com/firebase/quickstart-android/blob/master/messaging/app/src/main/java/com/google/firebase/quickstart/fcm/EntryChoiceActivity.kt
- add code:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
StrictMode.setVmPolicy(
StrictMode.VmPolicy.Builder()
.detectLeakedClosableObjects()
.penaltyLog()
.build()
)
}