Skip to content

Commit

Permalink
[hotfix-52032][core] Fix load dirty-plugins throws error of "Trying t…
Browse files Browse the repository at this point in the history
…o access closed classloader. Please check if you store classloaders directly or indirectly in static fields".
  • Loading branch information
tiezhu authored and FlechazoW committed Apr 11, 2022
1 parent 1c21978 commit 049b77c
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,11 @@ public static DirtyDataCollector discoverDirty(DirtyConf conf) {
try {
String pluginName = conf.getType();
String pluginClassName = PluginUtil.getPluginClassName(pluginName, OperatorType.dirty);
Set<URL> urlList =
PluginUtil.getJarFileDirPath(pluginName, conf.getLocalPluginPath(), null, "");

final DirtyDataCollector consumer =
ClassLoaderManager.newInstance(
urlList,
cl -> {
Class<?> clazz = cl.loadClass(pluginClassName);
Constructor<?> constructor = clazz.getConstructor();
return (DirtyDataCollector) constructor.newInstance();
});
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Class<?> clazz = classLoader.loadClass(pluginClassName);
Constructor<?> constructor = clazz.getConstructor();
final DirtyDataCollector consumer = (DirtyDataCollector) constructor.newInstance();
consumer.initializeConsumer(conf);
return consumer;
} catch (Exception e) {
Expand Down

0 comments on commit 049b77c

Please sign in to comment.