[
https://issues.apache.org/jira/browse/FLINK-31398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17698913#comment-17698913
]
luoyuxia commented on FLINK-31398:
----------------------------------
Just as the code said, we can remove it:
{code:java}
public ResultFetcher executeStatement(OperationHandle handle, String statement)
{
// Instantiate the TableEnvironment lazily
// TODO: remove the usage of the context classloader until {@link
// HiveParserUtils}#getFunctionInfo use ResourceManager explicitly.
try (TemporaryClassLoaderContext ignored =
TemporaryClassLoaderContext.of(
sessionContext.getSessionState().resourceManager.getUserClassLoader())) {
TableEnvironmentInternal tableEnv = getTableEnvironment();
List<Operation> parsedOperations =
tableEnv.getParser().parse(statement);
if (parsedOperations.size() > 1) {
throw new UnsupportedOperationException(
"Unsupported SQL statement! Execute statement only accepts
a single SQL statement or "
+ "multiple 'INSERT INTO' statements wrapped in a
'STATEMENT SET' block.");
}
Operation op = parsedOperations.get(0);
return sessionContext.isStatementSetState()
? executeOperationInStatementSetState(tableEnv, handle, op)
: executeOperation(tableEnv, handle, op);
}
} {code}
> Don't wrap with TemporaryClassLoaderContext in OperationExecutor
> ----------------------------------------------------------------
>
> Key: FLINK-31398
> URL: https://issues.apache.org/jira/browse/FLINK-31398
> Project: Flink
> Issue Type: Improvement
> Components: Connectors / Hive, Table SQL / Client
> Reporter: luoyuxia
> Priority: Major
>
> Currently, method OperationExecutor#executeStatement in sql client will wrap
> currently with `
> sessionContext.getSessionState().resourceManager.getUserClassLoader()`.
> Actually, it's not necessary. What' worse,
> it'll will cause the exception 'Trying to access closed classloader. Please
> check if you store xxx' after quiting sql client.
> The reason is in `ShutdownHookManager`, it will register a hook after jvm
> shutdown. In `ShutdownHookManager`, it will
> create `Configuration`. It will then access
> `Thread.currentThread().getContextClassLoader()` which is
> FlinkUserClassLoader, the FlinkUserClassLoader has been closed before. So,
> it'll then cause `'Trying to access closed classloader` exception.
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)