8230310: SocksSocketImpl should handle the IllegalArgumentException thrown by ProxySelector.select usage

Catch the IAE thrown by ProxySelector.select and wrap it into a IOException

Reviewed-by: dfuchs
This commit is contained in:
Jaikiran Pai 2019-08-28 20:05:43 +05:30
parent 1d71dd8604
commit 6fa4babbb2
2 changed files with 118 additions and 2 deletions

View file

@ -29,6 +29,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.BufferedOutputStream;
import java.security.AccessController;
import java.util.Iterator;
import jdk.internal.util.StaticProperty;
import sun.net.SocksProxy;
@ -327,8 +328,12 @@ class SocksSocketImpl extends DelegatingSocketImpl implements SocksConsts {
}
Proxy p = null;
IOException savedExc = null;
java.util.Iterator<Proxy> iProxy = null;
iProxy = sel.select(uri).iterator();
final Iterator<Proxy> iProxy;
try {
iProxy = sel.select(uri).iterator();
} catch (IllegalArgumentException iae) {
throw new IOException("Failed to select a proxy", iae);
}
if (iProxy == null || !(iProxy.hasNext())) {
delegate.connect(epoint, remainingMillis(deadlineMillis));
return;