activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5442
Date Tue, 25 Nov 2014 20:30:19 GMT
Repository: activemq
Updated Branches:
  refs/heads/trunk 46bc26cea -> 0514fcf88


https://issues.apache.org/jira/browse/AMQ-5442

Add check to avoid any NPE from stop without start called.

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/0514fcf8
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/0514fcf8
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/0514fcf8

Branch: refs/heads/trunk
Commit: 0514fcf8826efdba7544034d0000915f25f61437
Parents: 46bc26c
Author: Timothy Bish <tabish121@gmail.com>
Authored: Tue Nov 25 15:30:13 2014 -0500
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Tue Nov 25 15:30:13 2014 -0500

----------------------------------------------------------------------
 .../discovery/simple/SimpleDiscoveryAgent.java  | 34 ++++++++++++--------
 1 file changed, 21 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/0514fcf8/activemq-client/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java
b/activemq-client/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java
index cb7a235..726352b 100755
--- a/activemq-client/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java
@@ -30,8 +30,8 @@ import org.slf4j.LoggerFactory;
 /**
  * A simple DiscoveryAgent that allows static configuration of the discovered
  * services.
- * 
- * 
+ *
+ *
  */
 public class SimpleDiscoveryAgent implements DiscoveryAgent {
 
@@ -53,33 +53,36 @@ public class SimpleDiscoveryAgent implements DiscoveryAgent {
         private int connectFailures;
         private long reconnectDelay = initialReconnectDelay;
         private long connectTime = System.currentTimeMillis();
-        private AtomicBoolean failed = new AtomicBoolean(false);
+        private final AtomicBoolean failed = new AtomicBoolean(false);
 
         public SimpleDiscoveryEvent(String service) {
             super(service);
         }
 
-		public SimpleDiscoveryEvent(SimpleDiscoveryEvent copy) {
-			super(copy);
-			connectFailures = copy.connectFailures;
-			reconnectDelay = copy.reconnectDelay;
-			connectTime = copy.connectTime;
-			failed.set(copy.failed.get());
-		}
-        
+        public SimpleDiscoveryEvent(SimpleDiscoveryEvent copy) {
+            super(copy);
+            connectFailures = copy.connectFailures;
+            reconnectDelay = copy.reconnectDelay;
+            connectTime = copy.connectTime;
+            failed.set(copy.failed.get());
+        }
+
         @Override
         public String toString() {
             return "[" + serviceName + ", failed:" + failed + ", connectionFailures:" + connectFailures
+ "]";
         }
     }
 
+    @Override
     public void setDiscoveryListener(DiscoveryListener listener) {
         this.listener = listener;
     }
 
+    @Override
     public void registerService(String name) throws IOException {
     }
 
+    @Override
     public void start() throws Exception {
         taskRunner = new TaskRunnerFactory();
         taskRunner.init();
@@ -90,10 +93,13 @@ public class SimpleDiscoveryAgent implements DiscoveryAgent {
         }
     }
 
+    @Override
     public void stop() throws Exception {
         running.set(false);
 
-        taskRunner.shutdown();
+        if (taskRunner != null) {
+            taskRunner.shutdown();
+        }
 
         // TODO: Should we not remove the services on the listener?
 
@@ -121,6 +127,7 @@ public class SimpleDiscoveryAgent implements DiscoveryAgent {
         }
     }
 
+    @Override
     public void serviceFailed(DiscoveryEvent devent) throws IOException {
 
         final SimpleDiscoveryEvent sevent = (SimpleDiscoveryEvent)devent;
@@ -128,9 +135,10 @@ public class SimpleDiscoveryAgent implements DiscoveryAgent {
 
             listener.onServiceRemove(sevent);
             taskRunner.execute(new Runnable() {
+                @Override
                 public void run() {
                     SimpleDiscoveryEvent event = new SimpleDiscoveryEvent(sevent);
-                	
+
                     // We detect a failed connection attempt because the service
                     // fails right away.
                     if (event.connectTime + minConnectTime > System.currentTimeMillis())
{


Mime
View raw message