Repository: camel Updated Branches: refs/heads/camel-2.12.x 9195ef645 -> 32b6f773d refs/heads/camel-2.13.x 06b7d5c87 -> 6a75fdc11
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/6a75fdc1 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6a75fdc1 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6a75fdc1 Branch: refs/heads/camel-2.13.x Commit: 6a75fdc11df1d74a5baa25237fe3cddb01c64747 Parents: 06b7d5c 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:49:42 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/6a75fdc1/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/6a75fdc1/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);