On Tue, 9 Mar 2021 19:56:25 GMT, Patrick Concannon <pconcan...@openjdk.org> wrote:
>> Hi, >> >> Could someone please review my code for updating the code in the `java.net` >> and `java.nio` packages to make use of the `instanceof` pattern variable? >> >> Kind regards, >> Patrick > > Patrick Concannon has updated the pull request incrementally with one > additional commit since the last revision: > > 8263233: Refactored equals method further src/java.base/share/classes/java/net/NetMulticastSocket.java line 219: > 217: if (addr == null) > 218: addr = new InetSocketAddress(0); > 219: if (!(addr instanceof InetSocketAddress epoint)) in the context of this type of change the negative logic is a little obtuse or disjoint in the new style variable declaration, and its subsequent use. I'd find it a more natural flow and easier to read with the instance pattern prefacing a block in which the variable is used if (addr instanced InetSocketAddress epoint) { // a block which is using the epoint variable if (epoint.isUnresolved) throw new SocketException("Unresolved address"); InetAddress iaddr = epoint.getAddress; etc, etc ... } else { throw new IllegalArgumentException("Unsupported address type!"); } ------------- PR: https://git.openjdk.java.net/jdk/pull/2890