Project

General

Profile

NullPointerException in StreamManagementIOProcessor when trying to remove service

Raymond Chan
Added about 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
java.lang.NullPointerException
        at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)
        at java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1186)
        at tigase.server.xmppclient.StreamManagementIOProcessor.serviceStopped(StreamManagementIOProcessor.java:368)
        at tigase.xmpp.XMPPIOService.forceStop(XMPPIOService.java:257)
        at tigase.net.IOService.stop(IOService.java:476)
        at tigase.xmpp.XMPPIOService.stop(XMPPIOService.java:315)
        at tigase.server.ConnectionManager$Watchdog$1.check(ConnectionManager.java:1547)
        at tigase.server.ConnectionManager.doForAllServices(ConnectionManager.java:1008)
        at tigase.server.ConnectionManager$Watchdog.run(ConnectionManager.java:1509)
        at java.lang.Thread.run(Thread.java:744)

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/StreamManagementIOProcessor.java
+++ b/src/main/java/tigase/server/xmppclient/StreamManagementIOProcessor.java
@@ -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);
                                service.clearWaitingPackets();
                                connectionManager.serviceStopped(service);

Replies (3)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam about 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 about 4 years ago

I see... I'm using StreamManagementIOProcessor in this commit : https://projects.tigase.org/projects/tigase-server/repository/revisions/f8c9d4dd78a7d9b4b1a5ecabd002cf7bea817d61/entry/src/main/java/tigase/server/xmppclient/StreamManagementIOProcessor.java

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

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam about 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.

    (1-3/3)