NO-JIRA Fix Possible NPE in connectToNodeInReplicatedCluster
Variable possibleLive may be null, as signified by trace log above, also dedupe code.
This commit is contained in:
parent
3aebe74d07
commit
55732d401f
|
@ -213,23 +213,14 @@ 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;
|
||||
if (possibleLive != null) {
|
||||
clusterControl = tryConnectToNodeInReplicatedCluster(clusterController, possibleLive.getA());
|
||||
if (clusterControl == null) {
|
||||
clusterControl = tryConnectToNodeInReplicatedCluster(clusterController, possibleLive.getB());
|
||||
}
|
||||
} else {
|
||||
clusterControl = null;
|
||||
}
|
||||
}
|
||||
if (clusterControl == null) {
|
||||
|
||||
if (logger.isTraceEnabled()) {
|
||||
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue