tillrohrmann commented on a change in pull request #6876: [FLINK-10251] Handle 
oversized response messages in AkkaRpcActor
URL: https://github.com/apache/flink/pull/6876#discussion_r248238265
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/rpc/akka/AkkaInvocationHandler.java
 ##########
 @@ -205,12 +207,34 @@ private Object invokeRpc(Method method, Object[] args) 
throws Exception {
                        result = null;
                } else if (Objects.equals(returnType, CompletableFuture.class)) 
{
                        // execute an asynchronous call
-                       result = ask(rpcInvocation, futureTimeout);
+                       CompletableFuture resultFuture = ask(rpcInvocation, 
futureTimeout);
+
+                       result = resultFuture.thenApply((Object o) -> {
+                               if (o instanceof SerializedValue) {
+                                       try {
+                                               return  ((SerializedValue) 
o).deserializeValue(getClass().getClassLoader());
+                                       } catch (IOException | 
ClassNotFoundException e) {
+                                               throw new 
CompletionException(e);
+                                       }
+                               } else {
+                                       return o;
+                               }
+                       });
                } else {
                        // execute a synchronous call
-                       CompletableFuture<?> futureResult = ask(rpcInvocation, 
futureTimeout);
+                       CompletableFuture<?> resultFuture = ask(rpcInvocation, 
futureTimeout);
 
-                       result = futureResult.get(futureTimeout.getSize(), 
futureTimeout.getUnit());
+                       Object returnedResult = 
resultFuture.get(futureTimeout.getSize(), futureTimeout.getUnit());
+
+                       if (returnedResult instanceof SerializedValue) {
+                               try {
+                                       result = ((SerializedValue) 
returnedResult).deserializeValue(getClass().getClassLoader());
+                               } catch (IOException | ClassNotFoundException 
e) {
+                                       throw new CompletionException(e);
+                               }
+                       } else {
+                               result = returnedResult;
+                       }
 
 Review comment:
   This is somewhat a code duplication with the other branch. Could we 
deduplicate this code by applying the deserialization logic on the future? 
Additionally it would be good to catch `ExecutionException` when calling 
`resultFuture.get()` and unstrip them via 
`ExceptionUtils.unstripExecutionException`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to