You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2016/08/23 21:22:26 UTC

logging-log4j2 git commit: [LOG4J2-1320] Custom plugins are not loaded, URL protocol vfs is not supported. Added unit tests but they are @Ignore'd like the other tests of this type.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master e9a1bbe6d -> 2f0919887


[LOG4J2-1320] Custom plugins are not loaded, URL protocol vfs is not
supported. Added unit tests but they are @Ignore'd like the other tests
of this type.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2f091988
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2f091988
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2f091988

Branch: refs/heads/master
Commit: 2f0919887a5211b8c3121a656e497ca0b44000a9
Parents: e9a1bbe
Author: Gary Gregory <gg...@apache.org>
Authored: Tue Aug 23 14:22:18 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Tue Aug 23 14:22:18 2016 -0700

----------------------------------------------------------------------
 .../core/config/plugins/util/ResolverUtil.java  |  8 +++++++-
 .../config/plugins/util/ResolverUtilTest.java   | 20 ++++++++++++++++++++
 src/changes/changes.xml                         |  3 +++
 3 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2f091988/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
index b198490..14bf1e8 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java
@@ -84,6 +84,8 @@ public class ResolverUtil {
 
     private static final String VFSZIP = "vfszip";
 
+    private static final String VFS = "vfs";
+
     private static final String BUNDLE_RESOURCE = "bundleresource";
 
     /** The set of matches being accumulated. */
@@ -196,6 +198,10 @@ public class ResolverUtil {
                     } finally {
                         close(stream, newURL);
                     }
+                } else if (VFS.equals(url.getProtocol())) {
+                    final String path = urlPath.substring(1, urlPath.length() - packageName.length() - 2);
+                    final File file = new File(path);
+                    loadImplementationsInJar(test, packageName, file);
                 } else if (BUNDLE_RESOURCE.equals(url.getProtocol())) {
                     loadImplementationsInBundle(test, packageName);
                 } else {
@@ -232,7 +238,7 @@ public class ResolverUtil {
         // LOG4J2-445
         // Finally, decide whether to URL-decode the file name or not...
         final String protocol = url.getProtocol();
-        final List<String> neverDecode = Arrays.asList(VFSZIP, BUNDLE_RESOURCE);
+        final List<String> neverDecode = Arrays.asList(VFS, VFSZIP, BUNDLE_RESOURCE);
         if (neverDecode.contains(protocol)) {
             return urlPath;
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2f091988/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
index f7e7dac..cbcd23c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
@@ -105,6 +105,16 @@ public class ResolverUtilTest {
 
     @Ignore
     @Test
+    public void testExtractPathFromVfsUrl() throws Exception {
+        // need to install URLStreamHandlerFactory to prevent "unknown protocol" MalformedURLException
+        final URL url = new URL(
+                "vfs:/C:/jboss/jboss-eap-6.4/standalone/deployments/com.xxx.yyy.application-ear.ear/lib/com.xxx.yyy.logging.jar/com/xxx/yyy/logging/config/");
+        final String expected = "/jboss/jboss-eap-6.4/standalone/deployments/com.xxx.yyy.application-ear.ear/lib/com.xxx.yyy.logging.jar/com/xxx/yyy/logging/config/";
+        assertEquals(expected, new ResolverUtil().extractPath(url));
+    }
+
+    @Ignore
+    @Test
     public void testExtractPathFromVfszipUrlWithPlusCharacters()
             throws Exception {
         // need to install URLStreamHandlerFactory to prevent "unknown protocol" MalformedURLException
@@ -115,6 +125,16 @@ public class ResolverUtilTest {
 
     @Ignore
     @Test
+    public void testExtractPathFromVfsUrlWithPlusCharacters()
+            throws Exception {
+        // need to install URLStreamHandlerFactory to prevent "unknown protocol" MalformedURLException
+        final URL url = new URL("vfs:/path+with+plus/file+name+with+plus.xml");
+        final String expected = "/path+with+plus/file+name+with+plus.xml";
+        assertEquals(expected, new ResolverUtil().extractPath(url));
+    }
+
+    @Ignore
+    @Test
     public void testExtractPathFromResourceBundleUrl() throws Exception {
         // need to install URLStreamHandlerFactory to prevent "unknown protocol" MalformedURLException
         final URL url = new URL("resourcebundle:/some/path/some/file.properties");

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2f091988/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 42d61d0..d59c941 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,9 @@
   </properties>
   <body>
     <release version="2.7" date="2016-MM-DD" description="GA Release 2.7">
+      <action issue="LOG4J2-1320" dev="ggregory" type="fix" due-to="Paresh Varke, Pierrick Hymbert">
+        Custom plugins are not loaded, URL protocol vfs is not supported.
+      </action>
       <action issue="LOG4J2-1541" dev="ggregory" type="fix" due-to="Gary Gregory">
         Fix file handle resource leak in XmlConfiguration.XmlConfiguration(ConfigurationSource).
       </action>