NullPointerException in StreamManagementIOProcessor when trying to remove service

Raymond Chan
Added almost 4 years ago

Hi devs,

We're using Tigase 5.2.0 but cherry-picked the latest StreamManagementIOProcessor class and we ran into this exception:

2015-02-24 15:10:20.370 [Watchdog - c2s]   ThreadExceptionHandler.uncaughtException()  SEVERE: Uncaught thread: "Watchdog - c2s" exception
        at java.util.concurrent.ConcurrentHashMap.hash(
        at java.util.concurrent.ConcurrentHashMap.remove(
        at tigase.server.xmppclient.StreamManagementIOProcessor.serviceStopped(
        at tigase.xmpp.XMPPIOService.forceStop(
        at tigase.xmpp.XMPPIOService.stop(
        at tigase.server.ConnectionManager$Watchdog$1.check(
        at tigase.server.ConnectionManager.doForAllServices(
        at tigase.server.ConnectionManager$

Is it safe to do a null checking on id? If id is null then we'll do nothing.

--- a/src/main/java/tigase/server/xmppclient/
+++ b/src/main/java/tigase/server/xmppclient/
@@ -365,6 +365,10 @@ public class StreamManagementIOProcessor implements XMPPIOProcessor {
                        if ((System.currentTimeMillis() - resumptionTimeoutStart) > (2 * resumption_timeout * 1000)) {
                                // if so we should assume that resumption failed so we should
                                // send errors, remove reference to service and stop this service
+                               if (id == null) {
+                                       log.log(Level.WARNING, " attempting to remove serive, but id is null, abort");
+                                       return false;
+                               }
                                services.remove(id, service);

Replies (3)


Added by Artur Hefczyc TigaseTeam almost 4 years ago

What do you mean by "latest"? I have seen this NPE in the stream management code and as far as I remember it has been already fixed. There was a lot of changes in the stream management code between version 5.2.0 and 7.0.0, so I cannot guarantee that it will work if you just pick one class. On the other hand, I did not code this part of the server so I might be wrong.

Added by Raymond Chan almost 4 years ago

I see... I'm using StreamManagementIOProcessor in this commit :

Upgrading to 7.0.0 will still take some time for us, as we've done some modification base on 5.2.0, the above code would be as temp fix, just want to know if there are any impacts.

Thanks :)


Added by Artur Hefczyc TigaseTeam almost 4 years ago

It is really hard to advise you on impact because code change between these 2 versions is significant in all areas, lots of improvements and fixes. If you need a help with upgrading your code to version 7.0.0, let us know. We can help.