7088747: Use multicatch in Socket constructor
Reviewed-by: alanb
This commit is contained in:
parent
2eb4e18d75
commit
d961381c47
@ -420,15 +420,14 @@ class Socket implements java.io.Closeable {
|
||||
createImpl(stream);
|
||||
if (localAddr != null)
|
||||
bind(localAddr);
|
||||
if (address != null)
|
||||
connect(address);
|
||||
} catch (IOException e) {
|
||||
close();
|
||||
throw e;
|
||||
} finally {
|
||||
// if bind() or connect threw a runtime exception
|
||||
if ((localAddr != null && !bound) || (address != null && !connected))
|
||||
connect(address);
|
||||
} catch (IOException | IllegalArgumentException | SecurityException e) {
|
||||
try {
|
||||
close();
|
||||
} catch (IOException ce) {
|
||||
e.addSuppressed(ce);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user