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/08/31 21:01:36 UTC

[GitHub] [logging-log4j2] jvz commented on a change in pull request #392: [LOG4J2-2902] Add missing LoaderUtil permissions check

jvz commented on a change in pull request #392:
URL: https://github.com/apache/logging-log4j2/pull/392#discussion_r480396776



##########
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:
       You can use `assertDoesNotThrow(() -> ...);` to be more expressive about that than a comment.




----------------------------------------------------------------
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