You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/06/21 12:48:08 UTC

[camel] branch camel-2.24.x updated (ecdae37 -> 0e3afc0)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch camel-2.24.x
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from ecdae37  [CAMEL-12975]WARN: No CamelContext defined yet so cannot inject into bean: org.apache.camel.converter.jaxb.FallbackTypeConverter
     new e122aa9  CAMEL-13667
     new 0e3afc0  CAMEL-13667

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 camel-core/src/main/java/org/apache/camel/util/FileUtil.java  | 11 +++++++++--
 .../src/test/java/org/apache/camel/util/FileUtilTest.java     |  4 ++++
 2 files changed, 13 insertions(+), 2 deletions(-)


[camel] 02/02: CAMEL-13667

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-2.24.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0e3afc0aa6821bf9224e5e6266e4f0328fbb5f22
Author: cblamauer <52...@users.noreply.github.com>
AuthorDate: Thu Jun 20 17:21:52 2019 +0200

    CAMEL-13667
    
    Windows network UNC paths not treated correctly (File2/tempPrefix) test
---
 camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java b/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
index 59a2e82..4b024e3 100644
--- a/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
@@ -171,6 +171,8 @@ public class FileUtilTest extends Assert {
             assertEquals("foo\\bar\\baz", FileUtil.compactPath("foo\\bar\\.\\baz"));
             assertEquals("foo\\bar\\baz", FileUtil.compactPath("foo\\bar\\\\baz"));
             assertEquals("\\foo\\bar\\baz", FileUtil.compactPath("\\foo\\bar\\baz"));
+            // Test that multiple back-slashes at the beginning are preserved, this is necessary for network UNC paths.
+            assertEquals("\\\\foo\\bar\\baz", FileUtil.compactPath("\\\\foo\\bar\\baz"));
             assertEquals("\\", FileUtil.compactPath("\\"));
             assertEquals("\\", FileUtil.compactPath("/"));
             assertEquals("/", FileUtil.compactPath("\\", '/'));
@@ -190,6 +192,8 @@ public class FileUtilTest extends Assert {
             assertEquals("foo/bar/baz", FileUtil.compactPath("foo/bar/./baz"));
             assertEquals("foo/bar/baz", FileUtil.compactPath("foo/bar//baz"));
             assertEquals("/foo/bar/baz", FileUtil.compactPath("/foo/bar/baz"));
+            // Do not preserve multiple slashes at the beginning if not on Windows.
+            assertEquals("/foo/bar/baz", FileUtil.compactPath("//foo/bar/baz"));
             assertEquals("/", FileUtil.compactPath("/"));
             assertEquals("/", FileUtil.compactPath("\\"));
             assertEquals("/", FileUtil.compactPath("/", '/'));


[camel] 01/02: CAMEL-13667

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-2.24.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e122aa9b2fac94b2a3a152a97c7695fddfd6d8c7
Author: cblamauer <52...@users.noreply.github.com>
AuthorDate: Thu Jun 20 17:19:18 2019 +0200

    CAMEL-13667
    
    Windows network UNC paths not treated correctly (File2/tempPrefix)
---
 camel-core/src/main/java/org/apache/camel/util/FileUtil.java | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/camel-core/src/main/java/org/apache/camel/util/FileUtil.java b/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
index 632ab0b..f9c7d9e 100644
--- a/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
+++ b/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
@@ -300,7 +300,14 @@ public final class FileUtil {
         boolean endsWithSlash = path.endsWith("/") || path.endsWith("\\");
 
         // preserve starting slash if given in input path
-        boolean startsWithSlash = path.startsWith("/") || path.startsWith("\\");
+        int cntSlashsAtStart = 0;
+        if (path.startsWith("/") || path.startsWith("\\")) {
+            cntSlashsAtStart++;
+            // for Windows, preserve up to 2 starting slashes, which is necessary for UNC paths.
+            if (isWindows() && path.length() > 1 && (path.charAt(1) == '/' || path.charAt(1) == '\\')) {
+                cntSlashsAtStart++;
+            }
+        }
         
         Deque<String> stack = new ArrayDeque<>();
 
@@ -321,7 +328,7 @@ public final class FileUtil {
         // build path based on stack
         StringBuilder sb = new StringBuilder();
         
-        if (startsWithSlash) {
+        for (int i = 0; i < cntSlashsAtStart; i++) {
             sb.append(separator);
         }