A DESCRIPTION OF THE PROBLEM :
The 5-argument constructor of java.net.URI,
`URI(String scheme, String authority, String path, String query, String fragment)`
, is documented to:
1. Construct a URI string
2. Behave as if new URI is called with the given string and then parseServerAuthority is invoked.
The invocation of parseServerAuthority is:
1. Not actually performed when tried out (see code snippet below).
2. Nonsensical, since the constructor could be used to construct a registry-based URI (otherwise the 7-arg constructor should be used).
Example Snippet:
According to the documentation, the snippet should print:
Throw on 1
Throw on 2
However, it prints
Throw on 2
----
import java.net.URI;
import java.net.URISyntaxException;
public class Test {
public static void main(String[] args) {
try {
new URI(null, "my:registry", null, null, null);
} catch (URISyntaxException e) {
System.out.println("Throw on 1");
}
try {
new URI("//my:registry/").parseServerAuthority();
} catch (URISyntaxException e) {
System.out.println("Throw on 2");
}
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The resulting URI string is then parsed in order to create the new URI instance as if by invoking the URI(String) constructor; this may cause a URISyntaxException to be thrown.
ACTUAL -
The resulting URI string is then parsed as if by invoking the URI(String) constructor and then invoking the parseServerAuthority() method upon the result; this may cause a URISyntaxException to be thrown.
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/7/docs/api/java/net/URI.html#URI%28java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String%29
The 5-argument constructor of java.net.URI,
`URI(String scheme, String authority, String path, String query, String fragment)`
, is documented to:
1. Construct a URI string
2. Behave as if new URI is called with the given string and then parseServerAuthority is invoked.
The invocation of parseServerAuthority is:
1. Not actually performed when tried out (see code snippet below).
2. Nonsensical, since the constructor could be used to construct a registry-based URI (otherwise the 7-arg constructor should be used).
Example Snippet:
According to the documentation, the snippet should print:
Throw on 1
Throw on 2
However, it prints
Throw on 2
----
import java.net.URI;
import java.net.URISyntaxException;
public class Test {
public static void main(String[] args) {
try {
new URI(null, "my:registry", null, null, null);
} catch (URISyntaxException e) {
System.out.println("Throw on 1");
}
try {
new URI("//my:registry/").parseServerAuthority();
} catch (URISyntaxException e) {
System.out.println("Throw on 2");
}
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The resulting URI string is then parsed in order to create the new URI instance as if by invoking the URI(String) constructor; this may cause a URISyntaxException to be thrown.
ACTUAL -
The resulting URI string is then parsed as if by invoking the URI(String) constructor and then invoking the parseServerAuthority() method upon the result; this may cause a URISyntaxException to be thrown.
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/7/docs/api/java/net/URI.html#URI%28java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String%29