Skip to content

Commit 2b21a20

Browse files
committed
Block the execution of cluster tasks on non existing nodes
Also catch all exceptions (not only IllegalStateException) which occur if the node is not part of the cluster
1 parent a4967b1 commit 2b21a20

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/java/org/jivesoftware/openfire/plugin/util/cluster/ClusterPacketRouter.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.jivesoftware.openfire.plugin.util.cluster;
1818

1919
import org.jivesoftware.openfire.RemotePacketRouter;
20+
import org.jivesoftware.openfire.cluster.ClusterManager;
2021
import org.jivesoftware.util.cache.CacheFactory;
2122
import org.slf4j.Logger;
2223
import org.slf4j.LoggerFactory;
@@ -37,13 +38,16 @@ public class ClusterPacketRouter implements RemotePacketRouter {
3738

3839
private static Logger logger = LoggerFactory.getLogger(ClusterPacketRouter.class);
3940

40-
public boolean routePacket(byte[] nodeID, JID receipient, Packet packet) {
41+
public boolean routePacket(byte[] nodeID, JID recipient, Packet packet) {
4142
// Send the packet to the specified node and let the remote node deliver the packet to the recipient
4243
try {
43-
CacheFactory.doClusterTask(new RemotePacketExecution(receipient, packet), nodeID);
44+
if (!ClusterManager.isClusterMember(nodeID)) {
45+
return false;
46+
}
47+
CacheFactory.doClusterTask(new RemotePacketExecution(recipient, packet), nodeID);
4448
return true;
45-
} catch (IllegalStateException e) {
46-
logger.warn("Error while routing packet to remote node: " + e);
49+
} catch (Exception e) {
50+
logger.warn("Error while routing packet to remote node",e);
4751
return false;
4852
}
4953
}

0 commit comments

Comments
 (0)