You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2020/09/01 18:09:33 UTC
[GitHub] [logging-log4j2] rschmitt commented on a change in pull request #392: [LOG4J2-2902] Add missing LoaderUtil permissions check
rschmitt commented on a change in pull request #392:
URL: https://github.com/apache/logging-log4j2/pull/392#discussion_r481336032
##########
File path: log4j-api/src/test/java/org/apache/logging/log4j/util/LoaderUtilTest.java
##########
@@ -55,4 +62,52 @@ public void systemClassLoader() {
thread.setContextClassLoader(tccl);
}
}
+
+ @Test
+ public void securityManager() throws Exception {
+ String separator = System.getProperty("path.separator");
+ List<URL> classpath = new ArrayList<>();
+ for (String entry : System.getProperty("java.class.path").split(separator)) {
+ classpath.add(new File(entry).toURL());
+ }
+
+ URLClassLoader classLoader = new URLClassLoader(classpath.toArray(new URL[0]), null);
+ Class<?> thisClass = classLoader.loadClass("org.apache.logging.log4j.util.LoaderUtilTest");
+ Method getClassLoaders = thisClass.getMethod("runUnderSecurityManager");
+ getClassLoaders.invoke(null);
+ // no exception thrown
Review comment:
Neat! This does feel more satisfying (and surely yields a better error message too).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org