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);
|
createImpl(stream);
|
||||||
if (localAddr != null)
|
if (localAddr != null)
|
||||||
bind(localAddr);
|
bind(localAddr);
|
||||||
if (address != null)
|
connect(address);
|
||||||
connect(address);
|
} catch (IOException | IllegalArgumentException | SecurityException e) {
|
||||||
} catch (IOException e) {
|
try {
|
||||||
close();
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
// if bind() or connect threw a runtime exception
|
|
||||||
if ((localAddr != null && !bound) || (address != null && !connected))
|
|
||||||
close();
|
close();
|
||||||
|
} catch (IOException ce) {
|
||||||
|
e.addSuppressed(ce);
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user