ADDITIONAL SYSTEM INFORMATION :
Windows 10
Java 8 fails as described
Java 11 fails as described
Java 1.6/6 doesn't consider this a valid URL
A DESCRIPTION OF THE PROBLEM :
Create a URL that includes username and password where the username is an email address, basically including the @. When you call getUserInfo, it returns null. When you call getHost(), it returns an empty string. getFile() and getProtocol() work fine.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the included source
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
URL url = new URL("https://email@example.com:password@oracle.com/foobar");
System.out.println("Info: " + url.getUserInfo()); // email@example.com:password
System.out.println("Host: " + url.getHost()); // oracle.com
System.out.println("File: " + url.getFile()); // foobar
System.out.println("Prot: " + url.getProtocol()); // https
ACTUAL -
URL url = new URL("https://email@example.com:password@oracle.com/foobar");
System.out.println("Info: " + url.getUserInfo()); // null -- failure
System.out.println("Host: " + url.getHost()); // empty -- failure
System.out.println("File: " + url.getFile()); // works
System.out.println("Prot: " + url.getProtocol()); // works
---------- BEGIN SOURCE ----------
import java.net.*;
public class Test {
public static void main(String args[]) throws Exception {
URL url = new URL("https://email@example.com:password@oracle.com/foobar");
System.out.println("Info: " + url.getUserInfo()); // null
System.out.println("Host: " + url.getHost()); // empty
System.out.println("File: " + url.getFile()); // works
System.out.println("Prot: " + url.getProtocol()); // works
}
}
---------- END SOURCE ----------
FREQUENCY : always
Windows 10
Java 8 fails as described
Java 11 fails as described
Java 1.6/6 doesn't consider this a valid URL
A DESCRIPTION OF THE PROBLEM :
Create a URL that includes username and password where the username is an email address, basically including the @. When you call getUserInfo, it returns null. When you call getHost(), it returns an empty string. getFile() and getProtocol() work fine.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the included source
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
URL url = new URL("https://email@example.com:password@oracle.com/foobar");
System.out.println("Info: " + url.getUserInfo()); // email@example.com:password
System.out.println("Host: " + url.getHost()); // oracle.com
System.out.println("File: " + url.getFile()); // foobar
System.out.println("Prot: " + url.getProtocol()); // https
ACTUAL -
URL url = new URL("https://email@example.com:password@oracle.com/foobar");
System.out.println("Info: " + url.getUserInfo()); // null -- failure
System.out.println("Host: " + url.getHost()); // empty -- failure
System.out.println("File: " + url.getFile()); // works
System.out.println("Prot: " + url.getProtocol()); // works
---------- BEGIN SOURCE ----------
import java.net.*;
public class Test {
public static void main(String args[]) throws Exception {
URL url = new URL("https://email@example.com:password@oracle.com/foobar");
System.out.println("Info: " + url.getUserInfo()); // null
System.out.println("Host: " + url.getHost()); // empty
System.out.println("File: " + url.getFile()); // works
System.out.println("Prot: " + url.getProtocol()); // works
}
}
---------- END SOURCE ----------
FREQUENCY : always