wolfboys commented on code in PR #2243:
URL: 
https://github.com/apache/incubator-streampark/pull/2243#discussion_r1065390828


##########
streampark-common/src/main/scala/org/apache/streampark/common/util/CompletableFutureUtils.scala:
##########
@@ -56,7 +56,12 @@ object CompletableFutureUtils {
       unit: TimeUnit,
       handle: JavaFunc[T, T],
       exceptionally: JavaFunc[Throwable, T]): CompletableFuture[T] = {
-    future.applyToEither(setTimeout(timeout, unit), 
handle).exceptionally(exceptionally)
+    future
+      .applyToEither(setTimeout(timeout, unit), handle)
+      .exceptionally(exceptionally)
+      .whenComplete(new BiConsumer[T, Throwable]() {
+        override def accept(t: T, u: Throwable): Unit = future.cancel(true)

Review Comment:
   > Could you please add some unit tests to check the future is canceled after 
timeout?
   
   hi @1996fanrui :
   
   whenComplete is the completion of the call, run after future successful and 
exceptionally(Include timeout)



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to