Index: src/main/java/java/net/URI.java =================================================================== --- src/main/java/java/net/URI.java (revision 490299) +++ src/main/java/java/net/URI.java (working copy) @@ -414,21 +414,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; Index: src/test/java/tests/api/java/net/URITest.java =================================================================== --- src/test/java/tests/api/java/net/URITest.java (revision 490333) +++ src/test/java/tests/api/java/net/URITest.java (working copy) @@ -1480,6 +1480,9 @@ new URI("http", "[34:56::78]:80", "/path", "fragment") .parseServerAuthority(); + // Regression test for HARMONY-1126 + new URI("file://C:/1.txt").parseServerAuthority(); + // invalid authorities (neither server nor registry) try { URI uri = new URI("http://us[er@host:80/");