mirror of https://github.com/apache/activemq.git
Fix for possible NPE during start with immediate bridge failure.
This commit is contained in:
parent
bbc039fceb
commit
60bdfc061c
|
@ -107,7 +107,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
|
||||||
protected static final String DURABLE_SUB_PREFIX = "NC-DS_";
|
protected static final String DURABLE_SUB_PREFIX = "NC-DS_";
|
||||||
protected final Transport localBroker;
|
protected final Transport localBroker;
|
||||||
protected final Transport remoteBroker;
|
protected final Transport remoteBroker;
|
||||||
protected IdGenerator idGenerator;
|
protected IdGenerator idGenerator = new IdGenerator();
|
||||||
protected final LongSequenceGenerator consumerIdGenerator = new LongSequenceGenerator();
|
protected final LongSequenceGenerator consumerIdGenerator = new LongSequenceGenerator();
|
||||||
protected ConnectionInfo localConnectionInfo;
|
protected ConnectionInfo localConnectionInfo;
|
||||||
protected ConnectionInfo remoteConnectionInfo;
|
protected ConnectionInfo remoteConnectionInfo;
|
||||||
|
@ -381,8 +381,6 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
|
||||||
remoteBrokerName = remoteBrokerInfo.getBrokerName();
|
remoteBrokerName = remoteBrokerInfo.getBrokerName();
|
||||||
if (configuration.isUseBrokerNamesAsIdSeed()) {
|
if (configuration.isUseBrokerNamesAsIdSeed()) {
|
||||||
idGenerator = new IdGenerator(brokerService.getBrokerName() + "->" + remoteBrokerName);
|
idGenerator = new IdGenerator(brokerService.getBrokerName() + "->" + remoteBrokerName);
|
||||||
} else {
|
|
||||||
idGenerator = new IdGenerator();
|
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
serviceLocalException(e);
|
serviceLocalException(e);
|
||||||
|
@ -433,10 +431,15 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startLocalBridge() throws Throwable {
|
private void startLocalBridge() throws Throwable {
|
||||||
if (localBridgeStarted.compareAndSet(false, true)) {
|
if (!bridgeFailed.get() && localBridgeStarted.compareAndSet(false, true)) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
LOG.trace("{} starting local Bridge, localBroker={}", configuration.getBrokerName(), localBroker);
|
LOG.trace("{} starting local Bridge, localBroker={}", configuration.getBrokerName(), localBroker);
|
||||||
if (!disposed.get()) {
|
if (!disposed.get()) {
|
||||||
|
|
||||||
|
if (idGenerator == null) {
|
||||||
|
throw new IllegalStateException("Id Generator cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
localConnectionInfo = new ConnectionInfo();
|
localConnectionInfo = new ConnectionInfo();
|
||||||
localConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId()));
|
localConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId()));
|
||||||
localClientId = configuration.getName() + "_" + remoteBrokerName + "_inbound_" + configuration.getBrokerName();
|
localClientId = configuration.getName() + "_" + remoteBrokerName + "_inbound_" + configuration.getBrokerName();
|
||||||
|
@ -518,7 +521,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void startRemoteBridge() throws Exception {
|
protected void startRemoteBridge() throws Exception {
|
||||||
if (remoteBridgeStarted.compareAndSet(false, true)) {
|
if (!bridgeFailed.get() && remoteBridgeStarted.compareAndSet(false, true)) {
|
||||||
LOG.trace("{} starting remote Bridge, remoteBroker={}", configuration.getBrokerName(), remoteBroker);
|
LOG.trace("{} starting remote Bridge, remoteBroker={}", configuration.getBrokerName(), remoteBroker);
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (!isCreatedByDuplex()) {
|
if (!isCreatedByDuplex()) {
|
||||||
|
@ -810,8 +813,8 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
|
||||||
} else if (data.getClass() == RemoveSubscriptionInfo.class) {
|
} else if (data.getClass() == RemoveSubscriptionInfo.class) {
|
||||||
RemoveSubscriptionInfo info = ((RemoveSubscriptionInfo) data);
|
RemoveSubscriptionInfo info = ((RemoveSubscriptionInfo) data);
|
||||||
SubscriptionInfo subscriptionInfo = new SubscriptionInfo(info.getClientId(), info.getSubscriptionName());
|
SubscriptionInfo subscriptionInfo = new SubscriptionInfo(info.getClientId(), info.getSubscriptionName());
|
||||||
for (Iterator i = subscriptionMapByLocalId.values().iterator(); i.hasNext(); ) {
|
for (Iterator<DemandSubscription> i = subscriptionMapByLocalId.values().iterator(); i.hasNext(); ) {
|
||||||
DemandSubscription ds = (DemandSubscription) i.next();
|
DemandSubscription ds = i.next();
|
||||||
boolean removed = ds.getDurableRemoteSubs().remove(subscriptionInfo);
|
boolean removed = ds.getDurableRemoteSubs().remove(subscriptionInfo);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
if (ds.getDurableRemoteSubs().isEmpty()) {
|
if (ds.getDurableRemoteSubs().isEmpty()) {
|
||||||
|
|
Loading…
Reference in New Issue