Repository: camel Updated Branches: refs/heads/master 5c8b2e953 -> 7bd1a7dea
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/7bd1a7de Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7bd1a7de Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7bd1a7de Branch: refs/heads/master Commit: 7bd1a7dea8d5e8d441daf991f57c08a3aa3fb3bd Parents: 5c8b2e9 Author: Claus Ibsen <davscl...@apache.org> Authored: Thu May 8 09:48:02 2014 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Thu May 8 09:50:24 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/7bd1a7de/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 6212447..397beab 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/7bd1a7de/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);