camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] git commit: Fixed potential NPE in seda producer.
Date Thu, 08 May 2014 07:50:09 GMT
Fixed potential NPE in seda producer.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/32b6f773
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/32b6f773
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/32b6f773

Branch: refs/heads/camel-2.12.x
Commit: 32b6f773dbb870ea29e79277cf32c05117a62ed1
Parents: 9195ef6
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu May 8 09:48:02 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu May 8 09:49:56 2014 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/component/seda/SedaEndpoint.java  | 9 +++++----
 .../java/org/apache/camel/component/seda/SedaProducer.java  | 8 +++++++-
 2 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/32b6f773/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
index 7ee8d03..c8367dd 100644
--- a/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
@@ -179,12 +179,13 @@ public class SedaEndpoint extends DefaultEndpoint implements BrowsableEndpoint,
         }
     }
 
+    /**
+     * Get's the {@link QueueReference} for the this endpoint.
+     * @return the reference, or <tt>null</tt> if no queue reference exists.
+     */
     public synchronized QueueReference getQueueReference() {
         String key = getComponent().getQueueKey(getEndpointUri());
-        QueueReference ref =  getComponent().getQueueReference(key);
-        if (ref == null) {
-            LOG.warn("There was no queue reference for the endpoint {0}", getEndpointUri());
-        }
+        QueueReference ref = getComponent().getQueueReference(key);
         return ref;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/32b6f773/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java b/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java
index 379443d..81a2e4c 100644
--- a/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java
+++ b/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java
@@ -210,8 +210,14 @@ public class SedaProducer extends DefaultAsyncProducer {
      * @param exchange the exchange to add to the queue
      */
     protected void addToQueue(Exchange exchange) throws SedaConsumerNotAvailableException
{
+        BlockingQueue<Exchange> queue = null;
         QueueReference queueReference = endpoint.getQueueReference();
-        BlockingQueue<Exchange> queue = queueReference.getQueue();
+        if (queueReference != null) {
+            queue = queueReference.getQueue();
+        }
+        if (queue == null) {
+            throw new SedaConsumerNotAvailableException("No queue available on endpoint:
" + endpoint, exchange);
+        }
 
         if (endpoint.isFailIfNoConsumers() && !queueReference.hasConsumers()) {
             throw new SedaConsumerNotAvailableException("No consumers available on endpoint:
" + endpoint, exchange);


Mime
View raw message