From cdbc3f61583b339f508c54717a34bad16a00a681 Mon Sep 17 00:00:00 2001 From: Shengkai <33114724+fsk119@users.noreply.github.com> Date: Mon, 23 May 2022 15:57:31 +0800 Subject: [PATCH] [FLINK-24735][sql-client] Catch Throwable rather than Exception in LocalExecutor to avoid client crash This closes #19773. --- .../client/gateway/local/LocalExecutor.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/LocalExecutor.java b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/LocalExecutor.java index 3639ef8729e33..1540dec8f6535 100644 --- a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/LocalExecutor.java +++ b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/LocalExecutor.java @@ -170,8 +170,8 @@ public Operation parseStatement(String sessionId, String statement) List operations; try { operations = context.wrapClassLoader(() -> parser.parse(statement)); - } catch (Exception e) { - throw new SqlExecutionException("Failed to parse statement: " + statement, e); + } catch (Throwable t) { + throw new SqlExecutionException("Failed to parse statement: " + statement, t); } if (operations.isEmpty()) { throw new SqlExecutionException("Failed to parse statement: " + statement); @@ -207,8 +207,8 @@ public TableResultInternal executeOperation(String sessionId, Operation operatio (TableEnvironmentInternal) context.getTableEnvironment(); try { return context.wrapClassLoader(() -> tEnv.executeInternal(operation)); - } catch (Exception e) { - throw new SqlExecutionException(MESSAGE_SQL_EXECUTION_ERROR, e); + } catch (Throwable t) { + throw new SqlExecutionException(MESSAGE_SQL_EXECUTION_ERROR, t); } } @@ -220,8 +220,8 @@ public TableResultInternal executeModifyOperations( (TableEnvironmentInternal) context.getTableEnvironment(); try { return context.wrapClassLoader(() -> tEnv.executeInternal(operations)); - } catch (Exception e) { - throw new SqlExecutionException(MESSAGE_SQL_EXECUTION_ERROR, e); + } catch (Throwable t) { + throw new SqlExecutionException(MESSAGE_SQL_EXECUTION_ERROR, t); } } @@ -299,8 +299,8 @@ public void cancelQuery(String sessionId, String resultId) throws SqlExecutionEx try { // this operator will also stop flink job result.close(); - } catch (Exception e) { - throw new SqlExecutionException("Could not cancel the query execution", e); + } catch (Throwable t) { + throw new SqlExecutionException("Could not cancel the query execution", t); } resultStore.removeResult(resultId); }