deepstream.io-client-java icon indicating copy to clipboard operation
deepstream.io-client-java copied to clipboard

NPE when calling unsubscribe() while not subcribed

Open StephanSchuster opened this issue 7 years ago • 0 comments

Calling client.getEventHandler().unsubscribe("my/event", mMyListener) without having called client.getEventHandler().subscribe("my/event", mMyListener) before, results in an NPE in DeepstreamClientAbstract.onError(...)

Reason: The server sends NOT_SUBSCRIBED which is an event type that is not known by the respective Event enum on the client. Maybe this is already a bug. I'm not sure because on https://deepstreamhub.com/docs/server/constants-and-errors/ there is no check behind NOT_SUBSCRIBED for the client (whatever that means). In any case the client should handle such situations more gracefully with throwing a DeepstreamError instead of crashing with a NPE.

In contrast to other open issues there is no workaround for this by extending and fixing the client. All relevant methods cannot be overriden due to access rights. Therefore it would be very helpful if someone could fix and release this (maybe together with a few other issues).

I'll provide a patch shortly.

StephanSchuster avatar Oct 16 '18 13:10 StephanSchuster