This is an automated email from the ASF dual-hosted git repository.

mapohl pushed a commit to branch release-1.17
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.17 by this push:
     new 4ce41e14798 [FLINK-33116][tests] Fix 
CliClientTest.testCancelExecutionInteractiveMode fails with NPE
4ce41e14798 is described below

commit 4ce41e14798ccc3320a194ab7ab8eb5cb9ba5ed1
Author: Jiabao Sun <[email protected]>
AuthorDate: Thu Oct 12 14:58:44 2023 +0800

    [FLINK-33116][tests] Fix CliClientTest.testCancelExecutionInteractiveMode 
fails with NPE
---
 .../apache/flink/table/client/cli/CliClientTest.java   | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git 
a/flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/cli/CliClientTest.java
 
b/flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/cli/CliClientTest.java
index 9ce1fc1c808..43963004a40 100644
--- 
a/flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/cli/CliClientTest.java
+++ 
b/flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/cli/CliClientTest.java
@@ -20,6 +20,7 @@ package org.apache.flink.table.client.cli;
 
 import org.apache.flink.api.common.JobID;
 import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.testutils.CheckedThread;
 import org.apache.flink.runtime.testutils.CommonTestUtils;
 import org.apache.flink.table.api.DataTypes;
 import org.apache.flink.table.api.ResultKind;
@@ -294,14 +295,13 @@ class CliClientTest {
         try (Terminal terminal = TerminalUtils.createDumbTerminal(inputStream, 
outputStream);
                 CliClient client =
                         new CliClient(() -> terminal, mockExecutor, 
historyFilePath, null)) {
-            Thread thread =
-                    new Thread(
-                            () -> {
-                                try {
-                                    client.executeInInteractiveMode();
-                                } catch (Exception ignore) {
-                                }
-                            });
+            CheckedThread thread =
+                    new CheckedThread() {
+                        @Override
+                        public void go() {
+                            client.executeInInteractiveMode();
+                        }
+                    };
             thread.start();
 
             while (!mockExecutor.isAwait) {
@@ -311,6 +311,8 @@ class CliClientTest {
             terminal.raise(Terminal.Signal.INT);
             CommonTestUtils.waitUntilCondition(
                     () -> 
outputStream.toString().contains(CliStrings.MESSAGE_HELP));
+            // Prevent NPE when closing the terminal. See FLINK-33116 for more 
information.
+            thread.sync();
         }
     }
 

Reply via email to