提交 f48f140a 编写于 作者: M michaelm

7088747: Use multicatch in Socket constructor

Reviewed-by: alanb
上级 fe83109e
......@@ -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;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册