kreds icon indicating copy to clipboard operation
kreds copied to clipboard

NPE calling unsubscribe all with no prior subscriptions

Open WinteryFox opened this issue 1 year ago • 1 comments

Calling DefaultKredsSubscriberClient#unsubscribe with no parameters, to unsubscribe from all, results in NPE when there aren't any subscriptions.

Works if there has been a subscription before the call.

val subscriberClient = newSubscriberClient(Endpoint.from("..."), subscriber)
subscriberClient.subscribe("foo")
subscriberClient.unsubscribe()

Broken if called without any prior subscriptions.

val subscriberClient = newSubscriberClient(Endpoint.from("..."), subscriber)
subscriberClient.unsubscribe()

Stack trace below.

Exception in thread "DefaultDispatcher-worker-4" java.lang.NullPointerException: null cannot be cast to non-null type kotlin.String
	at io.github.crackthecodeabhi.kreds.connection.DefaultKredsSubscriberClient$Reader.processPubSubReply(PubSub.kt:529)
	at io.github.crackthecodeabhi.kreds.connection.DefaultKredsSubscriberClient$Reader.read(PubSub.kt:319)
	at io.github.crackthecodeabhi.kreds.connection.DefaultKredsSubscriberClient$Reader.access$read(PubSub.kt:275)
	at io.github.crackthecodeabhi.kreds.connection.DefaultKredsSubscriberClient$Reader$start$1.invokeSuspend(PubSub.kt:305)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith$$$capture(ContinuationImpl.kt:33)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:816)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@7750ce6b, Dispatchers.Default]

WinteryFox avatar Sep 03 '24 14:09 WinteryFox

@WinteryFox thanks for opening a issue, will check and let you know

crackthecodeabhi avatar Sep 07 '24 11:09 crackthecodeabhi