-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix use of AccessController in LoaderUtil #2138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This fixes issue apache#2129 where `AccessController::doPrivileged` is needlessly invoked when no `SecurityManager` is installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jvz,
Thank You for the fast fix!
Personally I think we should use as little SecurityManager
code as possible, see my remark below.
log4j-api/src/main/java/org/apache/logging/log4j/util/LoaderUtil.java
Outdated
Show resolved
Hide resolved
@jvz, would you also mind adding tests too, please? |
Turns out Android doesn't support Java 8 all that much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, although it would be nice to have an Android test.
static { | ||
if (System.getSecurityManager() != null) { | ||
boolean getClassLoaderDisabled; | ||
static final RuntimePermission GET_CLASS_LOADER = new RuntimePermission("getClassLoader"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I am mistaken, this is no longer necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used for checking if we have the ability to use the permission in full-permission mode to see if we should just fall back to the class loader of this class.
This fixes issue #2129 where
AccessController::doPrivileged
is needlessly invoked when noSecurityManager
is installed.