You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/01/16 07:00:18 UTC

[camel] branch master updated: CAMEL-13064: Multicast/splitter EIP should deal with iterators not honouring hasNext/next contract 100% accurate. The zip and tarfile iterators do not do that.

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 1dcef9f  CAMEL-13064: Multicast/splitter EIP should deal with iterators not honouring hasNext/next contract 100% accurate. The zip and tarfile iterators do not do that.
1dcef9f is described below

commit 1dcef9f13dac3512715235bd53216244299cbba1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jan 16 07:56:39 2019 +0100

    CAMEL-13064: Multicast/splitter EIP should deal with iterators not honouring hasNext/next contract 100% accurate. The zip and tarfile iterators do not do that.
---
 .../java/org/apache/camel/processor/MulticastProcessor.java  | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
index 5a2e9b6..90b36b2 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/MulticastProcessor.java
@@ -282,17 +282,23 @@ public class MulticastProcessor extends AsyncProcessorSupport implements Navigat
                 }
 
                 // Check if the iterator is empty
-                // This can only happen the very first time we check the existence
+                // This can happen the very first time we check the existence
                 // of an item before queuing the run.
+                // or some iterators may return true for hasNext() but then null in next()
                 if (!iterator.hasNext()) {
-                    doDone(null, true);
+                    doDone(result.get(), true);
                     return;
                 }
 
                 ProcessorExchangePair pair = iterator.next();
                 boolean hasNext = iterator.hasNext();
-                Exchange exchange = pair.getExchange();
+                // some iterators may return true for hasNext() but then null in next()
+                if (pair == null && !hasNext) {
+                    doDone(result.get(), true);
+                    return;
+                }
 
+                Exchange exchange = pair.getExchange();
                 int index = nbExchangeSent.getAndIncrement();
                 updateNewExchange(exchange, index, pairs, hasNext);