mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
8177648: getResponseCode() throws IllegalArgumentException caused by protocol error while following redirect
Reviewed-by: michaelm, chegar, dfuchs
This commit is contained in:
parent
ec24017b02
commit
1d67d474a5
5 changed files with 265 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -143,7 +143,9 @@ public abstract class ProxySelector {
|
|||
* contain one element of type
|
||||
* {@link java.net.Proxy Proxy}
|
||||
* that represents a direct connection.
|
||||
* @throws IllegalArgumentException if the argument is null
|
||||
* @throws IllegalArgumentException if the argument is null or if
|
||||
* the protocol or host cannot be determined from the provided
|
||||
* {@code uri}
|
||||
*/
|
||||
public abstract List<Proxy> select(URI uri);
|
||||
|
||||
|
|
|
@ -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 ||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue