harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r491780 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/URI.java test/java/tests/api/java/net/URITest.java
Date Tue, 02 Jan 2007 11:59:15 GMT
Author: tellison
Date: Tue Jan  2 03:59:13 2007
New Revision: 491780

URL: http://svn.apache.org/viewvc?view=rev&rev=491780
Log:
Apply patch HARMONY-1126 ([classlib][net] unexpected URISyntaxException for URI.parseServerAuthority())

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URI.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URITest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URI.java?view=diff&rev=491780&r1=491779&r2=491780
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URI.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URI.java Tue Jan 
2 03:59:13 2007
@@ -415,21 +415,24 @@
             if (index != -1 && endindex < index) {
                 // determine port and host
                 tempHost = temp.substring(0, index);
-                try {
-                    tempPort = Integer.parseInt(temp.substring(index + 1));
-                    if (tempPort < 0) {
+
+                if (index < (temp.length() - 1)) { // port part is not empty
+                    try {
+                        tempPort = Integer.parseInt(temp.substring(index + 1));
+                        if (tempPort < 0) {
+                            if (forceServer) {
+                                throw new URISyntaxException(authority, Msg
+                                        .getString("K00b1"), hostindex + index + 1); //$NON-NLS-1$
+                            }
+                            return;
+                        }
+                    } catch (NumberFormatException e) {
                         if (forceServer) {
                             throw new URISyntaxException(authority, Msg
                                     .getString("K00b1"), hostindex + index + 1); //$NON-NLS-1$
                         }
                         return;
                     }
-                } catch (NumberFormatException e) {
-                    if (forceServer) {
-                        throw new URISyntaxException(authority, Msg
-                                .getString("K00b1"), hostindex + index + 1); //$NON-NLS-1$
-                    }
-                    return;
                 }
             } else {
                 tempHost = temp;

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URITest.java?view=diff&rev=491780&r1=491779&r2=491780
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URITest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URITest.java
Tue Jan  2 03:59:13 2007
@@ -1517,6 +1517,9 @@
         } catch (URISyntaxException e) {
             // Expected
         }
+        
+        // regression test for HARMONY-1126
+        assertNotNull(URI.create("file://C:/1.txt").parseServerAuthority());
     }
 
     /**



Mime
View raw message