Skip to content

Commit 64ceb19

Browse files
authored
fix: use JetCacheExecutor.class 's class loader as JetCacheExecutor thread's context class loader (#975)
1 parent dddd031 commit 64ceb19

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

jetcache-core/src/main/java/com/alicp/jetcache/support/JetCacheExecutor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ public static ScheduledExecutorService defaultExecutor() {
4343
ThreadFactory tf = r -> {
4444
Thread t = new Thread(r, "JetCacheDefaultExecutor");
4545
t.setDaemon(true);
46+
47+
ClassLoader classLoader = JetCacheExecutor.class.getClassLoader();
48+
if (classLoader == null) {
49+
// This class was loaded by the Bootstrap ClassLoader,
50+
// so let's tie the thread's context ClassLoader to the System ClassLoader instead.
51+
classLoader = ClassLoader.getSystemClassLoader();
52+
}
53+
t.setContextClassLoader(classLoader);
54+
4655
return t;
4756
};
4857
int coreSize = Math.min(4, Runtime.getRuntime().availableProcessors());

0 commit comments

Comments
 (0)