8258422: Cleanup unnecessary null comparison before instanceof check in java.base

Reviewed-by: chegar, aefimov
This commit is contained in:
Andrey Turbanov 2021-01-11 23:30:44 +00:00 committed by Aleksei Efimov
parent ff54b77b76
commit 022bc9f0cb
22 changed files with 69 additions and 81 deletions

View file

@ -801,19 +801,19 @@ final class NetMulticastSocket extends MulticastSocket {
if (isClosed())
throw new SocketException("Socket is closed");
if (mcastaddr == null || !(mcastaddr instanceof InetSocketAddress))
if (!(mcastaddr instanceof InetSocketAddress addr))
throw new IllegalArgumentException("Unsupported address type");
if (oldImpl)
throw new UnsupportedOperationException();
checkAddress(((InetSocketAddress)mcastaddr).getAddress(), "joinGroup");
checkAddress(addr.getAddress(), "joinGroup");
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkMulticast(((InetSocketAddress)mcastaddr).getAddress());
security.checkMulticast(addr.getAddress());
}
if (!((InetSocketAddress)mcastaddr).getAddress().isMulticastAddress()) {
if (!addr.getAddress().isMulticastAddress()) {
throw new SocketException("Not a multicast address");
}
@ -826,19 +826,19 @@ final class NetMulticastSocket extends MulticastSocket {
if (isClosed())
throw new SocketException("Socket is closed");
if (mcastaddr == null || !(mcastaddr instanceof InetSocketAddress))
if (!(mcastaddr instanceof InetSocketAddress addr))
throw new IllegalArgumentException("Unsupported address type");
if (oldImpl)
throw new UnsupportedOperationException();
checkAddress(((InetSocketAddress)mcastaddr).getAddress(), "leaveGroup");
checkAddress(addr.getAddress(), "leaveGroup");
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkMulticast(((InetSocketAddress)mcastaddr).getAddress());
security.checkMulticast(addr.getAddress());
}
if (!((InetSocketAddress)mcastaddr).getAddress().isMulticastAddress()) {
if (!addr.getAddress().isMulticastAddress()) {
throw new SocketException("Not a multicast address");
}