Skip to content

Commit b5cdc9b

Browse files
committed
Merge branch '1.5_v3.8.1_bugfix_classloader' into '1.5_v3.8.1'
[flinksql][udf类加载器和tableEnv不是同一个][19234] See merge request !95
2 parents a49da13 + beb9b3a commit b5cdc9b

File tree

1 file changed

+3
-3
lines changed
  • core/src/main/java/com/dtstack/flink/sql

1 file changed

+3
-3
lines changed

core/src/main/java/com/dtstack/flink/sql/Main.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,14 @@ private static void registerUDF(SqlTree sqlTree, List<URL> jarURList, URLClassLo
249249
StreamTableEnvironment tableEnv)
250250
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
251251
//register urf
252-
// udf函数只能由appclassloader加载
253-
ClassLoader superClassLoader = Thread.currentThread().getContextClassLoader().getParent();
252+
// udf和tableEnv须由同一个类加载器加载
253+
ClassLoader levelClassLoader = tableEnv.getClass().getClassLoader();
254254
URLClassLoader classLoader = null;
255255
List<CreateFuncParser.SqlParserResult> funcList = sqlTree.getFunctionList();
256256
for (CreateFuncParser.SqlParserResult funcInfo : funcList) {
257257
//classloader
258258
if (classLoader == null) {
259-
classLoader = FlinkUtil.loadExtraJar(jarURList, (URLClassLoader)superClassLoader);
259+
classLoader = FlinkUtil.loadExtraJar(jarURList, (URLClassLoader)levelClassLoader);
260260
}
261261
FlinkUtil.registerUDF(funcInfo.getType(), funcInfo.getClassName(), funcInfo.getName(),
262262
tableEnv, classLoader);

0 commit comments

Comments
 (0)