OpenJDK / amber / amber
changeset 10439:b36f86ad26e1
7088747: Use multicatch in Socket constructor
Reviewed-by: alanb
author | michaelm |
---|---|
date | Fri, 09 Sep 2011 15:24:35 +0100 |
parents | 9607eb55d49f |
children | b90cf2f98868 |
files | jdk/src/share/classes/java/net/Socket.java |
diffstat | 1 files changed, 7 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/src/share/classes/java/net/Socket.java Fri Sep 09 14:14:01 2011 +0100 +++ b/jdk/src/share/classes/java/net/Socket.java Fri Sep 09 15:24:35 2011 +0100 @@ -420,15 +420,14 @@ createImpl(stream); if (localAddr != null) bind(localAddr); - if (address != null) - connect(address); - } catch (IOException e) { - close(); + connect(address); + } catch (IOException | IllegalArgumentException | SecurityException e) { + try { + close(); + } catch (IOException ce) { + e.addSuppressed(ce); + } throw e; - } finally { - // if bind() or connect threw a runtime exception - if ((localAddr != null && !bound) || (address != null && !connected)) - close(); } }