Hi,

Consider the following:

URL url = new URL("http", "", 80, "/image.gif", null);
String authority = url.getAuthority();
int port = url.getPort();

The authority here ends up as ":80" and the port as 80, the full string
representation "http://:80/image.gif";.

Note that if we pass null instead of the empty string for host, we end up
with a URL with a null authority and a -1 port. The URL string will be
"http:/image.gif".

Two things stand out from this observation:

1: This URL constructor treats null and empty string differently,
which seems strange
2: When passing the empty host component and a port != -1, the resulting
URL has a server-based authority component without any host part, which
seems strange

Is there a way out of this situation?

Eirik.

Reply via email to