{"action":"created","comment":{"url":"https://api.github.com/repos/mulesoft/mule/pulls/comments/92728206","pull_request_review_id":13249576,"id":92728206,"diff_hunk":"@@ -84,71 +86,69 @@ public DefaultExecutionMediator(ExtensionModel extensionModel, OperationModel op\n    * Executes the operation per the specification in this classes' javadoc\n    *\n    * @param executor an {@link OperationExecutor}\n-   * @param context the {@link ExecutionContextAdapter} for the {@code executor} to use\n+   * @param context  the {@link ExecutionContextAdapter} for the {@code executor} to use\n    * @return the operation's result\n    * @throws Exception if the operation or a {@link Interceptor#before(ExecutionContext)} invokation fails\n    */\n-  public Object execute(OperationExecutor executor, ExecutionContextAdapter context) throws Throwable {\n+  @Override\n+  public Publisher<Object> execute(OperationExecutor executor, ExecutionContextAdapter context) throws MuleException {\n     final List<Interceptor> interceptors = collectInterceptors(context.getConfiguration(), executor);\n-    final MutableConfigurationStats mutableStats = getMutableConfigurationStats(context);\n-    if (mutableStats != null) {\n-      mutableStats.addInflightOperation();\n-    }\n-    try {\n-      return executeWithRetryPolicy(executor, context, interceptors);\n-    } finally {\n-      if (mutableStats != null) {\n-        mutableStats.discountInflightOperation();\n-      }\n-    }\n-  }\n+    final Optional<MutableConfigurationStats> stats = getMutableConfigurationStats(context);\n+    stats.ifPresent(s -> s.addInflightOperation());\n \n-  private Object executeWithRetryPolicy(OperationExecutor executor, ExecutionContextAdapter context,\n-                                        List<Interceptor> interceptors)\n-      throws Throwable {\n-    RetryPolicyTemplate retryPolicyTemplate = getRetryPolicyTemplate(context.getConfiguration());\n-\n-    ExecutionTemplate<RetryContext> executionTemplate = getExecutionTemplate(context);\n-\n-    final OperationRetryCallBack connectionRetry = new OperationRetryCallBack(executor, context, interceptors);\n-    // TODO - MULE-9336 - Add support for non blocking retry policies\n-    // TODO - MULE-10579 - Reconnection should be centralized\n-    executionTemplate.execute(() -> retryPolicyTemplate.execute(connectionRetry, WORK_MANAGER));\n-    Throwable exception = connectionRetry.getOperationExecutionResult().getException();\n-    if (exception != null) {\n-      throw exception;\n+    try {\n+      return (Mono<Object>) getExecutionTemplate(context)\n+          .execute(() -> executeWithInterceptors(executor, context, interceptors, stats));\n+    } catch (Exception e) {\n+      throw new DefaultMuleException(e);\n     }\n-    return connectionRetry.getOperationExecutionResult().getOutput();\n   }\n \n-  private OperationExecutionResult executeWithInterceptors(OperationExecutor executor, ExecutionContextAdapter context,\n-                                                           List<Interceptor> interceptors,\n-                                                           ValueHolder<InterceptorsRetryRequest> retryRequestHolder) {\n-    Object result = null;\n-    Throwable exception = null;\n-\n+  private Mono<Object> executeWithInterceptors(OperationExecutor executor,\n+                                               ExecutionContextAdapter context,\n+                                               final List<Interceptor> interceptors,\n+                                               Optional<MutableConfigurationStats> stats) {\n \n-    InterceptorsExecutionResult beforeExecutionResult = before(context, interceptors);\n+    List<Interceptor> executedInterceptors = new ArrayList<>(interceptors.size());\n+    Mono<Object> publisher = Mono.create(sink -> {\n+      Mono<Object> result;\n \n-    try {\n+      InterceptorsExecutionResult beforeExecutionResult = before(context, interceptors);\n       if (beforeExecutionResult.isOk()) {\n-        result = executor.execute(context);\n-        onSuccess(context, result, interceptors);\n+        result = from(executor.execute(context));\n+        executedInterceptors.addAll(interceptors);\n       } else {\n-        interceptors = beforeExecutionResult.getExecutedInterceptors();\n-        throw beforeExecutionResult.getThrowable();\n+        result = error(beforeExecutionResult.getThrowable());\n+        executedInterceptors.addAll(beforeExecutionResult.getExecutedInterceptors());\n       }\n-    } catch (Throwable e) {\n-      exception = exceptionEnricherManager.processException(e);\n-      exception = moduleExceptionHandler.processException(exception);\n-      exception = onError(context, retryRequestHolder, exception, interceptors);\n-    } finally {\n-      after(context, result, interceptors);\n-    }\n \n-    return new OperationExecutionResult(result, exception, Optional.ofNullable(retryRequestHolder.get()));\n-  }\n+      result.doOnSuccess(value -> {\n+        onSuccess(context, value, interceptors);\n+        stats.ifPresent(s -> s.discountInflightOperation());\n+        sink.success(value);\n+      })\n+          .mapError(e -> {\n+            e = exceptionEnricherManager.processException(e);\n+            e = moduleExceptionHandler.processException(e);\n+            e = onError(context, e, interceptors);\n+\n+            return e;\n+          }).subscribe(value -> {","path":"modules/extensions-support/src/main/java/org/mule/runtime/module/extension/internal/runtime/operation/DefaultExecutionMediator.java","position":183,"original_position":183,"commit_id":"5be69fe71c1f2989e98e9b24c03ad1f52ec9d2d8","original_commit_id":"5be69fe71c1f2989e98e9b24c03ad1f52ec9d2d8","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":"Some comment(s) to explains what you are doing here?","created_at":"2016-12-16T00:10:46Z","updated_at":"2016-12-16T00:10:46Z","html_url":"https://github.com/mulesoft/mule/pull/3739#discussion_r92728206","pull_request_url":"https://api.github.com/repos/mulesoft/mule/pulls/3739","_links":{"self":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/comments/92728206"},"html":{"href":"https://github.com/mulesoft/mule/pull/3739#discussion_r92728206"},"pull_request":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/3739"}}},"pull_request":{"url":"https://api.github.com/repos/mulesoft/mule/pulls/3739","id":97632382,"html_url":"https://github.com/mulesoft/mule/pull/3739","diff_url":"https://github.com/mulesoft/mule/pull/3739.diff","patch_url":"https://github.com/mulesoft/mule/pull/3739.patch","issue_url":"https://api.github.com/repos/mulesoft/mule/issues/3739","number":3739,"state":"open","locked":false,"title":"MULE-10569: Support non-blocking operations in Ext-API","user":{"login":"marianogonzalez","id":1272771,"avatar_url":"https://avatars.githubusercontent.com/u/1272771?v=3","gravatar_id":"","url":"https://api.github.com/users/marianogonzalez","html_url":"https://github.com/marianogonzalez","followers_url":"https://api.github.com/users/marianogonzalez/followers","following_url":"https://api.github.com/users/marianogonzalez/following{/other_user}","gists_url":"https://api.github.com/users/marianogonzalez/gists{/gist_id}","starred_url":"https://api.github.com/users/marianogonzalez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marianogonzalez/subscriptions","organizations_url":"https://api.github.com/users/marianogonzalez/orgs","repos_url":"https://api.github.com/users/marianogonzalez/repos","events_url":"https://api.github.com/users/marianogonzalez/events{/privacy}","received_events_url":"https://api.github.com/users/marianogonzalez/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-12-12T21:01:03Z","updated_at":"2016-12-16T00:10:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d855f80ff7a4add68f939e4377e221fce7cfb8b0","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mulesoft/mule/pulls/3739/commits","review_comments_url":"https://api.github.com/repos/mulesoft/mule/pulls/3739/comments","review_comment_url":"https://api.github.com/repos/mulesoft/mule/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mulesoft/mule/issues/3739/comments","statuses_url":"https://api.github.com/repos/mulesoft/mule/statuses/5be69fe71c1f2989e98e9b24c03ad1f52ec9d2d8","head":{"label":"mulesoft:MULE-10569","ref":"MULE-10569","sha":"5be69fe71c1f2989e98e9b24c03ad1f52ec9d2d8","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}","deployments_url":"https://api.github.com/repos/mulesoft/mule/deployments","created_at":"2012-12-07T19:23:06Z","updated_at":"2016-12-15T16:54:15Z","pushed_at":"2016-12-15T21:45:37Z","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":239541,"stargazers_count":395,"watchers_count":395,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":395,"mirror_url":null,"open_issues_count":22,"forks":395,"open_issues":22,"watchers":395,"default_branch":"mule-4.x"}},"base":{"label":"mulesoft:mule-4.x","ref":"mule-4.x","sha":"775c19ecf1118dedc789070ad90cae4944ad06c4","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}","deployments_url":"https://api.github.com/repos/mulesoft/mule/deployments","created_at":"2012-12-07T19:23:06Z","updated_at":"2016-12-15T16:54:15Z","pushed_at":"2016-12-15T21:45:37Z","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":239541,"stargazers_count":395,"watchers_count":395,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":395,"mirror_url":null,"open_issues_count":22,"forks":395,"open_issues":22,"watchers":395,"default_branch":"mule-4.x"}},"_links":{"self":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/3739"},"html":{"href":"https://github.com/mulesoft/mule/pull/3739"},"issue":{"href":"https://api.github.com/repos/mulesoft/mule/issues/3739"},"comments":{"href":"https://api.github.com/repos/mulesoft/mule/issues/3739/comments"},"review_comments":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/3739/comments"},"review_comment":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/3739/commits"},"statuses":{"href":"https://api.github.com/repos/mulesoft/mule/statuses/5be69fe71c1f2989e98e9b24c03ad1f52ec9d2d8"}}}}
{"actor":{"display_login":"dfeist"}}