8177648: getResponseCode() throws IllegalArgumentException caused by protocol error while following redirect

Reviewed-by: michaelm, chegar, dfuchs
This commit is contained in:
Jaikiran Pai 2019-08-26 12:25:49 +01:00 committed by Michael McMahon
parent ec24017b02
commit 1d67d474a5
5 changed files with 265 additions and 4 deletions

View file

@ -44,6 +44,7 @@ import java.net.InetSocketAddress;
import java.net.URI;
import java.net.Proxy;
import java.net.ProxySelector;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Iterator;
import java.security.Permission;
@ -242,7 +243,13 @@ public class FtpURLConnection extends URLConnection {
});
if (sel != null) {
URI uri = sun.net.www.ParseUtil.toURI(url);
Iterator<Proxy> it = sel.select(uri).iterator();
final List<Proxy> proxies;
try {
proxies = sel.select(uri);
} catch (IllegalArgumentException iae) {
throw new IOException("Failed to select a proxy", iae);
}
final Iterator<Proxy> it = proxies.iterator();
while (it.hasNext()) {
p = it.next();
if (p == null || p == Proxy.NO_PROXY ||

View file

@ -1178,7 +1178,13 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
logger.finest("ProxySelector Request for " + uri);
}
Iterator<Proxy> it = sel.select(uri).iterator();
final List<Proxy> proxies;
try {
proxies = sel.select(uri);
} catch (IllegalArgumentException iae) {
throw new IOException("Failed to select a proxy", iae);
}
final Iterator<Proxy> it = proxies.iterator();
Proxy p;
while (it.hasNext()) {
p = it.next();