Visitar URL original
RegistrationIntentService leaks a closeable FileOutputStream · Issue #973 · firebase/firebase-cpp-sdk · GitHub
Skip to content

RegistrationIntentService leaks a closeable FileOutputStream #973

Description

@troys-code

[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:

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:

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        StrictMode.setVmPolicy(
            StrictMode.VmPolicy.Builder()
                .detectLeakedClosableObjects()
                .penaltyLog()
                .build()
        )
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions