7088747: Use multicatch in Socket constructor

Reviewed-by: alanb
This commit is contained in:
Michael McMahon 2011-09-09 15:24:35 +01:00
parent 2eb4e18d75
commit d961381c47

View File

@ -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;
}
}