mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8258422: Cleanup unnecessary null comparison before instanceof check in java.base
Reviewed-by: chegar, aefimov
This commit is contained in:
parent
ff54b77b76
commit
022bc9f0cb
22 changed files with 69 additions and 81 deletions
|
@ -213,9 +213,8 @@ abstract class AbstractPlainSocketImpl extends SocketImpl implements PlatformSoc
|
|||
throws IOException {
|
||||
boolean connected = false;
|
||||
try {
|
||||
if (address == null || !(address instanceof InetSocketAddress))
|
||||
if (!(address instanceof InetSocketAddress addr))
|
||||
throw new IllegalArgumentException("unsupported address type");
|
||||
InetSocketAddress addr = (InetSocketAddress) address;
|
||||
if (addr.isUnresolved())
|
||||
throw new UnknownHostException(addr.getHostName());
|
||||
// recording this.address as supplied by caller before calling connect
|
||||
|
@ -259,7 +258,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl implements PlatformSoc
|
|||
* PlainSocketImpl.setOption().
|
||||
*/
|
||||
case SO_LINGER:
|
||||
if (val == null || (!(val instanceof Integer) && !(val instanceof Boolean)))
|
||||
if (!(val instanceof Integer) && !(val instanceof Boolean))
|
||||
throw new SocketException("Bad parameter for option");
|
||||
if (val instanceof Boolean) {
|
||||
/* true only if disabling - enabling should be Integer */
|
||||
|
@ -267,7 +266,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl implements PlatformSoc
|
|||
}
|
||||
break;
|
||||
case SO_TIMEOUT:
|
||||
if (val == null || (!(val instanceof Integer)))
|
||||
if (!(val instanceof Integer))
|
||||
throw new SocketException("Bad parameter for SO_TIMEOUT");
|
||||
int tmp = ((Integer) val).intValue();
|
||||
if (tmp < 0)
|
||||
|
@ -275,7 +274,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl implements PlatformSoc
|
|||
timeout = tmp;
|
||||
break;
|
||||
case IP_TOS:
|
||||
if (val == null || !(val instanceof Integer)) {
|
||||
if (!(val instanceof Integer)) {
|
||||
throw new SocketException("bad argument for IP_TOS");
|
||||
}
|
||||
trafficClass = ((Integer)val).intValue();
|
||||
|
@ -283,35 +282,35 @@ abstract class AbstractPlainSocketImpl extends SocketImpl implements PlatformSoc
|
|||
case SO_BINDADDR:
|
||||
throw new SocketException("Cannot re-bind socket");
|
||||
case TCP_NODELAY:
|
||||
if (val == null || !(val instanceof Boolean))
|
||||
if (!(val instanceof Boolean))
|
||||
throw new SocketException("bad parameter for TCP_NODELAY");
|
||||
on = ((Boolean)val).booleanValue();
|
||||
break;
|
||||
case SO_SNDBUF:
|
||||
case SO_RCVBUF:
|
||||
if (val == null || !(val instanceof Integer) ||
|
||||
if (!(val instanceof Integer) ||
|
||||
!(((Integer)val).intValue() > 0)) {
|
||||
throw new SocketException("bad parameter for SO_SNDBUF " +
|
||||
"or SO_RCVBUF");
|
||||
}
|
||||
break;
|
||||
case SO_KEEPALIVE:
|
||||
if (val == null || !(val instanceof Boolean))
|
||||
if (!(val instanceof Boolean))
|
||||
throw new SocketException("bad parameter for SO_KEEPALIVE");
|
||||
on = ((Boolean)val).booleanValue();
|
||||
break;
|
||||
case SO_OOBINLINE:
|
||||
if (val == null || !(val instanceof Boolean))
|
||||
if (!(val instanceof Boolean))
|
||||
throw new SocketException("bad parameter for SO_OOBINLINE");
|
||||
on = ((Boolean)val).booleanValue();
|
||||
break;
|
||||
case SO_REUSEADDR:
|
||||
if (val == null || !(val instanceof Boolean))
|
||||
if (!(val instanceof Boolean))
|
||||
throw new SocketException("bad parameter for SO_REUSEADDR");
|
||||
on = ((Boolean)val).booleanValue();
|
||||
break;
|
||||
case SO_REUSEPORT:
|
||||
if (val == null || !(val instanceof Boolean))
|
||||
if (!(val instanceof Boolean))
|
||||
throw new SocketException("bad parameter for SO_REUSEPORT");
|
||||
if (!supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT))
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue