You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/04/04 01:23:22 UTC

svn commit: r1584464 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/FileUtils.java

Author: mattsicker
Date: Thu Apr  3 23:23:22 2014
New Revision: 1584464

URL: http://svn.apache.org/r1584464
Log:
Separate regex pattern into static field.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/FileUtils.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/FileUtils.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/FileUtils.java?rev=1584464&r1=1584463&r2=1584464&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/FileUtils.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/FileUtils.java Thu Apr  3 23:23:22 2014
@@ -25,6 +25,7 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLDecoder;
 
+import java.util.regex.Pattern;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.status.StatusLogger;
 
@@ -39,6 +40,7 @@ public final class FileUtils {
     private static final String JBOSS_FILE = "vfsfile";
 
     private static final Logger LOGGER = StatusLogger.getLogger();
+    private static final Pattern WINDOWS_DIRECTORY_SEPARATOR = Pattern.compile("\\\\+");
 
     private FileUtils() {
     }
@@ -111,6 +113,6 @@ public final class FileUtils {
      * @throws URISyntaxException if instantiating the URI threw a {@code URISyntaxException}.
      */
     public static URI getCorrectedFilePathUri(String uri) throws URISyntaxException {
-        return new URI(uri.replaceAll("\\\\+", "/"));
+        return new URI(WINDOWS_DIRECTORY_SEPARATOR.matcher(uri).replaceAll("/"));
     }
 }