You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ha...@apache.org on 2014/12/18 03:41:44 UTC
[14/17] activemq git commit:
https://issues.apache.org/jira/browse/AMQ-5315
https://issues.apache.org/jira/browse/AMQ-5315
Fix for possible NPE during start with immediate bridge failure.
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/41311df3
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/41311df3
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/41311df3
Branch: refs/heads/activemq-5.10.x
Commit: 41311df39cb5d5a667e46b447404a2c8e2447e5b
Parents: 0a6e217
Author: Timothy Bish <ta...@gmail.com>
Authored: Fri Aug 29 10:06:53 2014 -0400
Committer: Hadrian Zbarcea <ha...@apache.org>
Committed: Wed Dec 17 19:50:13 2014 -0500
----------------------------------------------------------------------
.../network/DemandForwardingBridgeSupport.java | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/41311df3/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java b/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
index 2242d73..f61c5ac 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
@@ -107,7 +107,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
protected static final String DURABLE_SUB_PREFIX = "NC-DS_";
protected final Transport localBroker;
protected final Transport remoteBroker;
- protected IdGenerator idGenerator;
+ protected IdGenerator idGenerator = new IdGenerator();
protected final LongSequenceGenerator consumerIdGenerator = new LongSequenceGenerator();
protected ConnectionInfo localConnectionInfo;
protected ConnectionInfo remoteConnectionInfo;
@@ -381,8 +381,6 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
remoteBrokerName = remoteBrokerInfo.getBrokerName();
if (configuration.isUseBrokerNamesAsIdSeed()) {
idGenerator = new IdGenerator(brokerService.getBrokerName() + "->" + remoteBrokerName);
- } else {
- idGenerator = new IdGenerator();
}
} catch (Throwable e) {
serviceLocalException(e);
@@ -433,10 +431,15 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
}
private void startLocalBridge() throws Throwable {
- if (localBridgeStarted.compareAndSet(false, true)) {
+ if (!bridgeFailed.get() && localBridgeStarted.compareAndSet(false, true)) {
synchronized (this) {
LOG.trace("{} starting local Bridge, localBroker={}", configuration.getBrokerName(), localBroker);
if (!disposed.get()) {
+
+ if (idGenerator == null) {
+ throw new IllegalStateException("Id Generator cannot be null");
+ }
+
localConnectionInfo = new ConnectionInfo();
localConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId()));
localClientId = configuration.getName() + "_" + remoteBrokerName + "_inbound_" + configuration.getBrokerName();
@@ -518,7 +521,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
}
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);
synchronized (this) {
if (!isCreatedByDuplex()) {
@@ -810,8 +813,8 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
} else if (data.getClass() == RemoveSubscriptionInfo.class) {
RemoveSubscriptionInfo info = ((RemoveSubscriptionInfo) data);
SubscriptionInfo subscriptionInfo = new SubscriptionInfo(info.getClientId(), info.getSubscriptionName());
- for (Iterator i = subscriptionMapByLocalId.values().iterator(); i.hasNext(); ) {
- DemandSubscription ds = (DemandSubscription) i.next();
+ for (Iterator<DemandSubscription> i = subscriptionMapByLocalId.values().iterator(); i.hasNext(); ) {
+ DemandSubscription ds = i.next();
boolean removed = ds.getDurableRemoteSubs().remove(subscriptionInfo);
if (removed) {
if (ds.getDurableRemoteSubs().isEmpty()) {