camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1347886 - /camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
Date Fri, 08 Jun 2012 06:08:02 GMT
Author: davsclaus
Date: Fri Jun  8 06:08:01 2012
New Revision: 1347886

URL: http://svn.apache.org/viewvc?rev=1347886&view=rev
Log:
Fixed a potential NPE when shutting down a seda consumer, which hasn't properly been started
prior to shutdown.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java?rev=1347886&r1=1347885&r2=1347886&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
Fri Jun  8 06:08:01 2012
@@ -57,7 +57,7 @@ public class SedaConsumer extends Servic
     private static final transient Logger LOG = LoggerFactory.getLogger(SedaConsumer.class);
 
     private final AtomicInteger taskCount = new AtomicInteger();
-    private CountDownLatch latch;
+    private volatile CountDownLatch latch;
     private volatile boolean shutdownPending;
     private SedaEndpoint endpoint;
     private AsyncProcessor processor;
@@ -111,13 +111,15 @@ public class SedaConsumer extends Servic
         // signal we want to shutdown
         shutdownPending = true;
 
-        LOG.debug("Preparing to shutdown, waiting for {} consumer threads to complete.",
latch.getCount());
+        if (latch != null) {
+            LOG.debug("Preparing to shutdown, waiting for {} consumer threads to complete.",
latch.getCount());
 
-        // wait for all threads to end
-        try {
-            latch.await();
-        } catch (InterruptedException e) {
-            // ignore
+            // wait for all threads to end
+            try {
+                latch.await();
+            } catch (InterruptedException e) {
+                // ignore
+            }
         }
     }
 



Mime
View raw message