Unverified Commit 98891a54 authored by Licho's avatar Licho Committed by GitHub

fix: 1.14 1.15 classloader (#2667)

* fix: 1.14 1.15 classloader Signed-off-by: 's avatarlicho <lecho.sun@gmail.com> * Spotless Apply * refactor: 14 15 set currentThread classloader Signed-off-by: 's avatarlicho <lecho.sun@gmail.com> * Spotless Apply * refactor: remove other current thread set classloader Signed-off-by: 's avatarlicho <lecho.sun@gmail.com> --------- Signed-off-by: 's avatarlicho <lecho.sun@gmail.com> Co-authored-by: 's avatarleechor <leechor@users.noreply.github.com>
parent 6366ecd8
......@@ -20,7 +20,6 @@
package org.dinky.aop;
import org.dinky.data.exception.DinkyException;
import org.dinky.job.JobResult;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
......@@ -51,7 +50,7 @@ public class UdfClassLoaderAspect {
@Around("allPointcut()")
public Object round(ProceedingJoinPoint proceedingJoinPoint) {
Object proceed = null;
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
proceed = proceedingJoinPoint.proceed();
} catch (Throwable e) {
......@@ -61,7 +60,9 @@ public class UdfClassLoaderAspect {
e.printStackTrace();
throw (DinkyException) e;
} finally {
if (proceed instanceof JobResult) {}
if (contextClassLoader != Thread.currentThread().getContextClassLoader()) {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
return proceed;
}
......
......@@ -78,8 +78,6 @@ public final class EmailSender {
return alertResult;
}
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
String sendResult = MailUtil.send(
getMailAccount(),
......
......@@ -119,6 +119,7 @@ public class CustomTableEnvironmentImpl extends AbstractCustomTableEnvironment {
executor,
isStreamingMode,
userClassLoader));
Thread.currentThread().setContextClassLoader(userClassLoader);
this.executor = executor;
injectParser(new CustomParserImpl(getPlanner().getParser()));
injectExtendedExecutor(new CustomExtendedOperationExecutorImpl(this));
......
......@@ -108,6 +108,7 @@ public class CustomTableEnvironmentImpl extends AbstractCustomTableEnvironment {
executor,
isStreamingMode,
userClassLoader));
Thread.currentThread().setContextClassLoader(userClassLoader);
injectParser(new CustomParserImpl(getPlanner().getParser()));
injectExtendedExecutor(new CustomExtendedOperationExecutorImpl(this));
}
......
......@@ -60,7 +60,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.URLUtil;
/**
......@@ -152,9 +151,6 @@ public abstract class Executor {
if (executorConfig.isValidVariables()) {
variableManager.registerVariable(executorConfig.getVariables());
}
// Fix the Classloader in the env above Flink1.16 to appClassLoader, causing ckp to fail to compile
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
ReflectUtil.setFieldValue(environment, "userClassloader", contextClassLoader);
}
abstract CustomTableEnvironment createCustomTableEnvironment(ClassLoader classLoader);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment