When a HttpURLConnection encounters a redirect, it attempts to parse the
redirect URL. This may be a relative URL, however it is parsed as an
absolute URL. Consequently, a relative URL appearing in the redirect
header will result in a Malformed URLException rather than the correct
redirection behavior.
The underlying bug is in the class
sun.net.www.protocol.http.HttpURLConnection
in the method
followRedirect()
in the statment
locUrl = new URL(loc);
Which should be using the two-argument version of the URL constructor.