{"action":"created","comment":{"url":"https://api.github.com/repos/mulesoft/mule/pulls/comments/28825086","id":28825086,"diff_hunk":"@@ -0,0 +1,140 @@\n+/*\n+ * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com\n+ * The software in this package is published under the terms of the CPAL v1.0\n+ * license, a copy of which has been included with this distribution in the\n+ * LICENSE.txt file.\n+ */\n+package org.mule.processor.chain;\n+\n+import org.mule.MessageExchangePattern;\n+import org.mule.OptimizedRequestContext;\n+import org.mule.VoidMuleEvent;\n+import org.mule.api.MessagingException;\n+import org.mule.api.MuleEvent;\n+import org.mule.api.component.Component;\n+import org.mule.api.endpoint.OutboundEndpoint;\n+import org.mule.api.processor.MessageProcessor;\n+import org.mule.api.service.Service;\n+import org.mule.api.transformer.Transformer;\n+import org.mule.api.transport.NonBlockingResponseReplyToHandler;\n+import org.mule.execution.MessageProcessorExecutionTemplate;\n+import org.mule.processor.AbstractInterceptingMessageProcessorBase;\n+import org.mule.routing.MessageFilter;\n+\n+import java.util.List;\n+\n+/**\n+ * Iterates over a list of {@link org.mule.api.processor.MessageProcessor}'s processing them one by one using the result\n+ * of the first processor to invoke the second and so on.  MessageProcessor implementations aside from simply iterating\n+ * over processors implement rules regarding if and when iteration should stop early or even stop temporarily and be\n+ * continued later.\n+ * <p/>\n+ * This implementation processes each {@link org.mule.api.processor.MessageProcessor} in sucession in the same thread\n+ * until or processors have been invoked or one of the following is returned by a processor:\n+ * <li>{@link org.mule.VoidMuleEvent}</li>\n+ * <li><code>null</code></li>\n+ */\n+public class ProcessorIterator\n+{\n+\n+    final protected MessageProcessorExecutionTemplate messageProcessorExecutionTemplate;\n+    final protected boolean copyOnVoidEvent;\n+    final protected List<MessageProcessor> processors;\n+\n+    protected volatile int index;\n+    protected MuleEvent event;\n+\n+    public ProcessorIterator(MuleEvent event, List<MessageProcessor> processors,\n+                             MessageProcessorExecutionTemplate messageProcessorExecutionTemplate, boolean copyOnVoidEvent)\n+    {\n+        this.event = event;\n+        this.processors = processors;\n+        this.copyOnVoidEvent = copyOnVoidEvent;\n+        this.messageProcessorExecutionTemplate = messageProcessorExecutionTemplate;\n+    }\n+\n+    public MuleEvent process() throws MessagingException\n+    {\n+        while (continueProcessing())\n+        {\n+            event = processNext();\n+        }\n+        return event;\n+    }\n+\n+    protected boolean continueProcessing()\n+    {\n+        return index < processors.size() && event != null && !VoidMuleEvent.isVoid(event);\n+    }\n+\n+    protected MuleEvent processNext() throws MessagingException\n+    {\n+        MessageProcessor processor = nextProcessor();\n+\n+        preProcess(processor);\n+\n+        if (copyOnVoidEvent && processorMayReturnVoidEvent(processor))\n+        {\n+            MuleEvent copy = OptimizedRequestContext.criticalSetEvent(event);\n+            MuleEvent result = messageProcessorExecutionTemplate.execute(processor, event);\n+            if (VoidMuleEvent.getInstance().equals(result))\n+            {\n+                result = copy;\n+            }\n+            return result;\n+        }\n+        else\n+        {\n+            return messageProcessorExecutionTemplate.execute(processor, event);\n+        }\n+    }\n+\n+    protected void preProcess(MessageProcessor processor)\n+    {\n+        // template method.\n+    }\n+\n+    protected MessageProcessor nextProcessor()\n+    {\n+        return processors.get(index++);\n+    }\n+\n+    private boolean processorMayReturnVoidEvent(MessageProcessor processor)","path":"core/src/main/java/org/mule/processor/chain/ProcessorIterator.java","position":102,"original_position":102,"commit_id":"46ea354229f7ffdd8c064532e5476cb6941af6e1","original_commit_id":"46ea354229f7ffdd8c064532e5476cb6941af6e1","user":{"login":"pablokraan","id":561399,"avatar_url":"https://avatars.githubusercontent.com/u/561399?v=3","gravatar_id":"","url":"https://api.github.com/users/pablokraan","html_url":"https://github.com/pablokraan","followers_url":"https://api.github.com/users/pablokraan/followers","following_url":"https://api.github.com/users/pablokraan/following{/other_user}","gists_url":"https://api.github.com/users/pablokraan/gists{/gist_id}","starred_url":"https://api.github.com/users/pablokraan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pablokraan/subscriptions","organizations_url":"https://api.github.com/users/pablokraan/orgs","repos_url":"https://api.github.com/users/pablokraan/repos","events_url":"https://api.github.com/users/pablokraan/events{/privacy}","received_events_url":"https://api.github.com/users/pablokraan/received_events","type":"User","site_admin":false},"body":"processorMayReturnVoidEvent > mayProcessorReturnVoidEvent?","created_at":"2015-04-21T21:38:30Z","updated_at":"2015-04-21T21:38:30Z","html_url":"https://github.com/mulesoft/mule/pull/1613#discussion_r28825086","pull_request_url":"https://api.github.com/repos/mulesoft/mule/pulls/1613","_links":{"self":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/comments/28825086"},"html":{"href":"https://github.com/mulesoft/mule/pull/1613#discussion_r28825086"},"pull_request":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/1613"}}},"pull_request":{"url":"https://api.github.com/repos/mulesoft/mule/pulls/1613","id":33758736,"html_url":"https://github.com/mulesoft/mule/pull/1613","diff_url":"https://github.com/mulesoft/mule/pull/1613.diff","patch_url":"https://github.com/mulesoft/mule/pull/1613.patch","issue_url":"https://api.github.com/repos/mulesoft/mule/issues/1613","number":1613,"state":"open","locked":false,"title":"MULE-8511 Add support for non blocking processing of flows","user":{"login":"dfeist","id":380765,"avatar_url":"https://avatars.githubusercontent.com/u/380765?v=3","gravatar_id":"","url":"https://api.github.com/users/dfeist","html_url":"https://github.com/dfeist","followers_url":"https://api.github.com/users/dfeist/followers","following_url":"https://api.github.com/users/dfeist/following{/other_user}","gists_url":"https://api.github.com/users/dfeist/gists{/gist_id}","starred_url":"https://api.github.com/users/dfeist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dfeist/subscriptions","organizations_url":"https://api.github.com/users/dfeist/orgs","repos_url":"https://api.github.com/users/dfeist/repos","events_url":"https://api.github.com/users/dfeist/events{/privacy}","received_events_url":"https://api.github.com/users/dfeist/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-21T13:04:54Z","updated_at":"2015-04-21T21:38:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"27cc1a246440db617222f87a538d8bf18abc5654","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mulesoft/mule/pulls/1613/commits","review_comments_url":"https://api.github.com/repos/mulesoft/mule/pulls/1613/comments","review_comment_url":"https://api.github.com/repos/mulesoft/mule/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mulesoft/mule/issues/1613/comments","statuses_url":"https://api.github.com/repos/mulesoft/mule/statuses/46ea354229f7ffdd8c064532e5476cb6941af6e1","head":{"label":"mulesoft:MULE-8511","ref":"MULE-8511","sha":"46ea354229f7ffdd8c064532e5476cb6941af6e1","user":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"repo":{"id":7058562,"name":"mule","full_name":"mulesoft/mule","owner":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mulesoft/mule","description":"Mule Community Edition","fork":false,"url":"https://api.github.com/repos/mulesoft/mule","forks_url":"https://api.github.com/repos/mulesoft/mule/forks","keys_url":"https://api.github.com/repos/mulesoft/mule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mulesoft/mule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mulesoft/mule/teams","hooks_url":"https://api.github.com/repos/mulesoft/mule/hooks","issue_events_url":"https://api.github.com/repos/mulesoft/mule/issues/events{/number}","events_url":"https://api.github.com/repos/mulesoft/mule/events","assignees_url":"https://api.github.com/repos/mulesoft/mule/assignees{/user}","branches_url":"https://api.github.com/repos/mulesoft/mule/branches{/branch}","tags_url":"https://api.github.com/repos/mulesoft/mule/tags","blobs_url":"https://api.github.com/repos/mulesoft/mule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mulesoft/mule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mulesoft/mule/git/refs{/sha}","trees_url":"https://api.github.com/repos/mulesoft/mule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mulesoft/mule/statuses/{sha}","languages_url":"https://api.github.com/repos/mulesoft/mule/languages","stargazers_url":"https://api.github.com/repos/mulesoft/mule/stargazers","contributors_url":"https://api.github.com/repos/mulesoft/mule/contributors","subscribers_url":"https://api.github.com/repos/mulesoft/mule/subscribers","subscription_url":"https://api.github.com/repos/mulesoft/mule/subscription","commits_url":"https://api.github.com/repos/mulesoft/mule/commits{/sha}","git_commits_url":"https://api.github.com/repos/mulesoft/mule/git/commits{/sha}","comments_url":"https://api.github.com/repos/mulesoft/mule/comments{/number}","issue_comment_url":"https://api.github.com/repos/mulesoft/mule/issues/comments{/number}","contents_url":"https://api.github.com/repos/mulesoft/mule/contents/{+path}","compare_url":"https://api.github.com/repos/mulesoft/mule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mulesoft/mule/merges","archive_url":"https://api.github.com/repos/mulesoft/mule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mulesoft/mule/downloads","issues_url":"https://api.github.com/repos/mulesoft/mule/issues{/number}","pulls_url":"https://api.github.com/repos/mulesoft/mule/pulls{/number}","milestones_url":"https://api.github.com/repos/mulesoft/mule/milestones{/number}","notifications_url":"https://api.github.com/repos/mulesoft/mule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mulesoft/mule/labels{/name}","releases_url":"https://api.github.com/repos/mulesoft/mule/releases{/id}","created_at":"2012-12-07T19:23:06Z","updated_at":"2015-04-21T19:35:18Z","pushed_at":"2015-04-21T20:50:48Z","git_url":"git://github.com/mulesoft/mule.git","ssh_url":"git@github.com:mulesoft/mule.git","clone_url":"https://github.com/mulesoft/mule.git","svn_url":"https://github.com/mulesoft/mule","homepage":null,"size":419676,"stargazers_count":181,"watchers_count":181,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":244,"mirror_url":null,"open_issues_count":16,"forks":244,"open_issues":16,"watchers":181,"default_branch":"mule-3.x"}},"base":{"label":"mulesoft:mule-3.x","ref":"mule-3.x","sha":"355bddb9534508d03d3886072f579f4eee3399dc","user":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"repo":{"id":7058562,"name":"mule","full_name":"mulesoft/mule","owner":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mulesoft/mule","description":"Mule Community Edition","fork":false,"url":"https://api.github.com/repos/mulesoft/mule","forks_url":"https://api.github.com/repos/mulesoft/mule/forks","keys_url":"https://api.github.com/repos/mulesoft/mule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mulesoft/mule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mulesoft/mule/teams","hooks_url":"https://api.github.com/repos/mulesoft/mule/hooks","issue_events_url":"https://api.github.com/repos/mulesoft/mule/issues/events{/number}","events_url":"https://api.github.com/repos/mulesoft/mule/events","assignees_url":"https://api.github.com/repos/mulesoft/mule/assignees{/user}","branches_url":"https://api.github.com/repos/mulesoft/mule/branches{/branch}","tags_url":"https://api.github.com/repos/mulesoft/mule/tags","blobs_url":"https://api.github.com/repos/mulesoft/mule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mulesoft/mule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mulesoft/mule/git/refs{/sha}","trees_url":"https://api.github.com/repos/mulesoft/mule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mulesoft/mule/statuses/{sha}","languages_url":"https://api.github.com/repos/mulesoft/mule/languages","stargazers_url":"https://api.github.com/repos/mulesoft/mule/stargazers","contributors_url":"https://api.github.com/repos/mulesoft/mule/contributors","subscribers_url":"https://api.github.com/repos/mulesoft/mule/subscribers","subscription_url":"https://api.github.com/repos/mulesoft/mule/subscription","commits_url":"https://api.github.com/repos/mulesoft/mule/commits{/sha}","git_commits_url":"https://api.github.com/repos/mulesoft/mule/git/commits{/sha}","comments_url":"https://api.github.com/repos/mulesoft/mule/comments{/number}","issue_comment_url":"https://api.github.com/repos/mulesoft/mule/issues/comments{/number}","contents_url":"https://api.github.com/repos/mulesoft/mule/contents/{+path}","compare_url":"https://api.github.com/repos/mulesoft/mule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mulesoft/mule/merges","archive_url":"https://api.github.com/repos/mulesoft/mule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mulesoft/mule/downloads","issues_url":"https://api.github.com/repos/mulesoft/mule/issues{/number}","pulls_url":"https://api.github.com/repos/mulesoft/mule/pulls{/number}","milestones_url":"https://api.github.com/repos/mulesoft/mule/milestones{/number}","notifications_url":"https://api.github.com/repos/mulesoft/mule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mulesoft/mule/labels{/name}","releases_url":"https://api.github.com/repos/mulesoft/mule/releases{/id}","created_at":"2012-12-07T19:23:06Z","updated_at":"2015-04-21T19:35:18Z","pushed_at":"2015-04-21T20:50:48Z","git_url":"git://github.com/mulesoft/mule.git","ssh_url":"git@github.com:mulesoft/mule.git","clone_url":"https://github.com/mulesoft/mule.git","svn_url":"https://github.com/mulesoft/mule","homepage":null,"size":419676,"stargazers_count":181,"watchers_count":181,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":244,"mirror_url":null,"open_issues_count":16,"forks":244,"open_issues":16,"watchers":181,"default_branch":"mule-3.x"}},"_links":{"self":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/1613"},"html":{"href":"https://github.com/mulesoft/mule/pull/1613"},"issue":{"href":"https://api.github.com/repos/mulesoft/mule/issues/1613"},"comments":{"href":"https://api.github.com/repos/mulesoft/mule/issues/1613/comments"},"review_comments":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/1613/comments"},"review_comment":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/1613/commits"},"statuses":{"href":"https://api.github.com/repos/mulesoft/mule/statuses/46ea354229f7ffdd8c064532e5476cb6941af6e1"}}}}