Commit 1c961a26 authored by Tom Evans's avatar Tom Evans

OF-864: Wrap primary routing in try/catch block

Ensure that all packets are handled by the backup routing mechanism in
the event that an exception occurs during primary packet processing.
parent 44409e75
......@@ -233,6 +233,7 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust
*/
public void routePacket(JID jid, Packet packet, boolean fromServer) throws PacketException {
boolean routed = false;
try {
if (serverName.equals(jid.getDomain())) {
// Packet sent to our domain.
routed = routeToLocalDomain(jid, packet, fromServer);
......@@ -245,10 +246,19 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust
// Packet sent to remote server
routed = routeToRemoteDomain(jid, packet, routed);
}
} catch (Exception ex) {
// Catch here to ensure that all packets get handled, despite various processing
// exceptions, rather than letting any fall through the cracks. For example,
// an IAE could be thrown when running in a cluster if a remote member becomes
// unavailable before the routing caches are updated to remove the defunct node.
// We have also occasionally seen various flavors of NPE and other oddities,
// typically due to unexpected environment or logic breakdowns.
Log.error("Primary packet routing failed", ex);
}
if (!routed) {
if (Log.isDebugEnabled()) {
Log.debug("RoutingTableImpl: Failed to route packet to JID: {} packet: {}", jid, packet.toXML());
Log.debug("Failed to route packet to JID: {} packet: {}", jid, packet.toXML());
}
if (packet instanceof IQ) {
iqRouter.routingFailed(jid, packet);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment