jerrypeng commented on a change in pull request #10370:
URL: https://github.com/apache/pulsar/pull/10370#discussion_r627842825



##########
File path: 
pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java
##########
@@ -317,46 +322,79 @@ private void setupStateStore() throws Exception {
         }
     }
 
-    private void processResult(Record srcRecord,
-                               CompletableFuture<JavaExecutionResult> result) 
throws Exception {
-        result.whenComplete((result1, throwable) -> {
-            if (throwable != null || result1.getUserException() != null) {
-                Throwable t = throwable != null ? throwable : 
result1.getUserException();
-                log.warn("Encountered exception when processing message {}",
+    private void processResult(@SuppressWarnings("rawtypes") Record srcRecord,
+                               JavaExecutionResult result) throws 
SinkException {
+       
+       if (result.getUserException() != null) {
+               stats.incrUserExceptions(result.getUserException());

Review comment:
       still seems to be some formatting issues

##########
File path: 
pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java
##########
@@ -317,46 +322,79 @@ private void setupStateStore() throws Exception {
         }
     }
 
-    private void processResult(Record srcRecord,
-                               CompletableFuture<JavaExecutionResult> result) 
throws Exception {
-        result.whenComplete((result1, throwable) -> {
-            if (throwable != null || result1.getUserException() != null) {
-                Throwable t = throwable != null ? throwable : 
result1.getUserException();
-                log.warn("Encountered exception when processing message {}",
+    private void processResult(@SuppressWarnings("rawtypes") Record srcRecord,
+                               JavaExecutionResult result) throws 
SinkException {
+       
+       if (result.getUserException() != null) {
+               stats.incrUserExceptions(result.getUserException());
+            srcRecord.fail();
+            return;
+       }
+       
+       if (result.isAsync()) {
+          result.getFuture().whenComplete((result1, throwable) -> {
+              if (throwable != null) {
+                  Throwable t = throwable;
+                  log.warn("Encountered exception when processing message {}",
                         srcRecord, t);
-                stats.incrUserExceptions(t);
-                srcRecord.fail();
-            } else {
-                if (result1.getResult() != null) {
-                    sendOutputMessage(srcRecord, result1.getResult());
-                } else {
+                  stats.incrUserExceptions(t);
+                  srcRecord.fail();
+              } else {
+                  if (result1 != null) {
+                       try {
+                      sendOutputMessage(srcRecord, result1);
+                                       } catch (SinkException e) {

Review comment:
       formatting issue?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to