Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,21 @@ private GetClassLoader() {
}

public static ClassLoader fromContext() {
return Thread.currentThread().getContextClassLoader();
if (System.getSecurityManager() == null) {
// Fast path when no SecurityManager is active
return Thread.currentThread().getContextClassLoader();
} else {
// Use AccessController when SecurityManager is active
return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> {
ClassLoader tccl = null;
try {
tccl = Thread.currentThread().getContextClassLoader();
} catch (SecurityException ex) {
LOG.warn("Unable to get context classloader instance.", ex);
}
return tccl;
});
}
}

public static ClassLoader fromClass(Class<?> clazz) {
Expand Down
Loading