You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/11/14 09:31:09 UTC

[GitHub] [flink] 1996fanrui commented on a diff in pull request #21304: [FLINK-30003][rpc] Wait the scheduler future is done before check

1996fanrui commented on code in PR #21304:
URL: https://github.com/apache/flink/pull/21304#discussion_r1021261838


##########
flink-rpc/flink-rpc-akka/src/test/java/org/apache/flink/runtime/rpc/akka/ContextClassLoadingSettingTest.java:
##########
@@ -150,21 +154,28 @@ void testAkkaRpcService_ScheduleRunnableSetsFlinkContextClassLoader()
     void testAkkaRpcService_ScheduleRunnableWithFixedRateSetsFlinkContextClassLoader() {
         final int numberOfScheduledRuns = 2;
         final List<ClassLoader> contextClassLoaders = new ArrayList<>(numberOfScheduledRuns);
-        akkaRpcService
-                .getScheduledExecutor()
-                .scheduleAtFixedRate(
-                        () -> {
-                            if (contextClassLoaders.size() < numberOfScheduledRuns) {
-                                contextClassLoaders.add(
-                                        Thread.currentThread().getContextClassLoader());
-                            } else {
-                                throw new RuntimeException("cancel task");
-                            }
-                        },
-                        0,
-                        1,
-                        TimeUnit.MILLISECONDS);
-
+        ScheduledFuture<?> future =
+                akkaRpcService
+                        .getScheduledExecutor()
+                        .scheduleAtFixedRate(
+                                () -> {
+                                    if (contextClassLoaders.size() < numberOfScheduledRuns) {
+                                        contextClassLoaders.add(
+                                                Thread.currentThread().getContextClassLoader());
+                                    } else {
+                                        throw new RuntimeException("cancel task");
+                                    }
+                                },
+                                0,
+                                1,
+                                TimeUnit.MILLISECONDS);
+        try {
+            future.get();
+            fail("The future should fail.");

Review Comment:
   Hi @zentol , Thanks for your review, I updated.



-- 
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: issues-unsubscribe@flink.apache.org

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