On Wed, 20 Nov 2024 08:28:10 GMT, Alan Bateman <al...@openjdk.org> wrote:
>> Volkan Yazıcı has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Apply review feedback from Alan > > src/java.base/share/classes/java/net/Socket.java line 503: > >> 501: // `connect()` already closes the socket on failures, yet >> `bind()` doesn't, and hence: >> 502: closeQuietly(throwable); >> 503: throw throwable; > > Would you mind adding `assert address instanceof InetSocketAddress isa && > !isa.isUnresolved();` to the start of this (private) constructor as that will > ensure we have the right pre-conditions and avoid further discussion about > other socket address types. If you take on board the other feedback then you can reduce the scope of the try-catch to just the bind, e.g. if (localAddr != null) { try { bind(localAddr); } catch (Throwable ex) { try { close(); } catch (Throwable ce) { ex.addSuppressed(ce); } throw ex; } } connect(address); // closes Socket if it throws ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22160#discussion_r1849847977