camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1225766 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/util/URISupport.java test/java/org/apache/camel/util/URISupportTest.java
Date Fri, 30 Dec 2011 07:22:46 GMT
Author: ningjiang
Date: Fri Dec 30 07:22:45 2011
New Revision: 1225766

URL: http://svn.apache.org/viewvc?rev=1225766&view=rev
Log:
CAMEL-4841 Fixed the issue that URI normalization duplicates query if path is empty

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/URISupport.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/URISupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/URISupport.java?rev=1225766&r1=1225765&r2=1225766&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/URISupport.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/URISupport.java Fri Dec 30
07:22:45 2011
@@ -259,9 +259,11 @@ public final class URISupport {
             path = path.substring(2);
         }
         int idx = path.indexOf('?');
-        if (idx > 0) {
+        // when the path has ?
+        if (idx != -1) {
             path = path.substring(0, idx);
         }
+        
         path = UnsafeUriCharactersEncoder.encode(path);
 
         // in case there are parameters we should reorder them

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java?rev=1225766&r1=1225765&r2=1225766&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java Fri Dec
30 07:22:45 2011
@@ -48,6 +48,12 @@ public class URISupportTest extends Cont
         out1 = URISupport.normalizeUri("seda:foo?concurrentConsumer=2");
         out2 = URISupport.normalizeUri("seda:foo");
         assertNotSame(out1, out2);
+        
+        out1 = URISupport.normalizeUri("foo:?test=1");
+        out2 = URISupport.normalizeUri("foo://?test=1");
+        assertEquals("foo://?test=1", out2);
+        assertEquals(out1, out2);
+        
     }
 
     public void testNormalizeEndpointUriNoParam() throws Exception {



Mime
View raw message