提交 f48f140a 编写于 作者: M michaelm

7088747: Use multicatch in Socket constructor

Reviewed-by: alanb
上级 fe83109e
...@@ -420,15 +420,14 @@ class Socket implements java.io.Closeable { ...@@ -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 e) { } catch (IOException | IllegalArgumentException | SecurityException e) {
try {
close(); close();
} catch (IOException ce) {
e.addSuppressed(ce);
}
throw e; throw e;
} finally {
// if bind() or connect threw a runtime exception
if ((localAddr != null && !bound) || (address != null && !connected))
close();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册