diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java index 4c360f08a4..587b8f0181 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java @@ -213,22 +213,13 @@ public final class SharedNothingBackupActivation extends Activation { activeMQServer.getNodeManager().setNodeID(nodeID); } - try { - if (logger.isTraceEnabled()) { - logger.trace("Calling clusterController.connectToNodeInReplicatedCluster(" + possibleLive != null ? possibleLive.getA() : null + ")"); - } - clusterControl = clusterController.connectToNodeInReplicatedCluster(possibleLive.getA()); - } catch (Exception e) { - logger.debug(e.getMessage(), e); - if (possibleLive != null && possibleLive.getB() != null) { - try { - clusterControl = clusterController.connectToNodeInReplicatedCluster(possibleLive.getB()); - } catch (Exception e1) { - clusterControl = null; - } - } else { - clusterControl = null; + if (possibleLive != null) { + clusterControl = tryConnectToNodeInReplicatedCluster(clusterController, possibleLive.getA()); + if (clusterControl == null) { + clusterControl = tryConnectToNodeInReplicatedCluster(clusterController, possibleLive.getB()); } + } else { + clusterControl = null; } if (clusterControl == null) { @@ -367,6 +358,20 @@ public final class SharedNothingBackupActivation extends Activation { } } + private static ClusterControl tryConnectToNodeInReplicatedCluster(ClusterController clusterController, TransportConfiguration tc) { + try { + if (logger.isTraceEnabled()) { + logger.trace("Calling clusterController.connectToNodeInReplicatedCluster(" + tc + ")"); + } + if (tc != null) { + return clusterController.connectToNodeInReplicatedCluster(tc); + } + } catch (Exception e) { + logger.debug(e.getMessage(), e); + } + return null; + } + @Override public void close(final boolean permanently, boolean restarting) throws Exception { synchronized (this) {