A DESCRIPTION OF THE PROBLEM :
As I understand URL is a subset of URI, so I ran into an interesting case where the following two output gave different results
@ParameterizedTest
@ValueSource(
strings = {"http://127.0.0.1:8081", "http://dev-test:8081", "http://dev-test.01:8081"})
void testURLAddresses(String inputAddress) {
assertDoesNotThrow(
() -> {
final URL url = new URL(inputAddress);
new InetSocketAddress(url.getHost(), url.getPort());
});
}
@ParameterizedTest
@ValueSource(
strings = {"http://127.0.0.1:8081", "http://dev-test:8081", "http://dev-test.01:8081"})
void testURIAddresses(String inputAddress) {
assertDoesNotThrow(
() -> {
final URI url = new URI(inputAddress);
new InetSocketAddress(url.getHost(), url.getPort());
});
}
The last case for the address "http://dev-test.01:8081" , getHost() works for URLs but for URI throws an java.lang.IllegalArgumentException: hostname can't be null
FREQUENCY : always
As I understand URL is a subset of URI, so I ran into an interesting case where the following two output gave different results
@ParameterizedTest
@ValueSource(
strings = {"http://127.0.0.1:8081", "http://dev-test:8081", "http://dev-test.01:8081"})
void testURLAddresses(String inputAddress) {
assertDoesNotThrow(
() -> {
final URL url = new URL(inputAddress);
new InetSocketAddress(url.getHost(), url.getPort());
});
}
@ParameterizedTest
@ValueSource(
strings = {"http://127.0.0.1:8081", "http://dev-test:8081", "http://dev-test.01:8081"})
void testURIAddresses(String inputAddress) {
assertDoesNotThrow(
() -> {
final URI url = new URI(inputAddress);
new InetSocketAddress(url.getHost(), url.getPort());
});
}
The last case for the address "http://dev-test.01:8081" , getHost() works for URLs but for URI throws an java.lang.IllegalArgumentException: hostname can't be null
FREQUENCY : always