Skip to content

MqttClientPersistence opened by ConnectActionListener is not closed #876

@milosfec

Description

@milosfec

I've checked the source code on found out that MqttAsyncClient passes MqttClientPersistence instance to ConnectActionListener and it's being open upon calling connect(), but it's never closed.

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:1986)
	at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:336)
	at java.io.RandomAccessFile.finalize(RandomAccessFile.java:1238)
	at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:319)
	at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:306)
	at java.lang.Daemons$Daemon.run(Daemons.java:140)
	at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.Throwable: Explicit termination method 'close' not called
	at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:288)
	at dalvik.system.CloseGuard.open(CloseGuard.java:257)
	at java.io.RandomAccessFile.<init>(RandomAccessFile.java:292)
	at org.eclipse.paho.client.mqttv3.internal.FileLock.<init>(FileLock.java:49)
	at org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence.open(MqttDefaultFilePersistence.java:120)
	at org.eclipse.paho.client.mqttv3.internal.ConnectActionListener.connect(ConnectActionListener.java:174)
	at org.eclipse.paho.client.mqttv3.MqttAsyncClient.connect(MqttAsyncClient.java:766)
	at info.mqtt.android.service.MqttConnection.connect(MqttConnection.kt:177)
	at info.mqtt.android.service.MqttService$connect$1.invokeSuspend(MqttService.kt:295)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:124)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions