@@ -235,9 +235,9 @@ protected void leave(InetAddress inetaddr) throws IOException {
235235
236236 protected void joinGroup (SocketAddress mcastaddr , NetworkInterface netIf )
237237 throws IOException {
238- if (mcastaddr == null || !(mcastaddr instanceof InetSocketAddress ))
238+ if (!(mcastaddr instanceof InetSocketAddress addr ))
239239 throw new IllegalArgumentException ("Unsupported address type" );
240- join ((( InetSocketAddress ) mcastaddr ) .getAddress (), netIf );
240+ join (addr .getAddress (), netIf );
241241 }
242242
243243 protected abstract void join (InetAddress inetaddr , NetworkInterface netIf )
@@ -253,9 +253,9 @@ protected abstract void join(InetAddress inetaddr, NetworkInterface netIf)
253253 */
254254 protected void leaveGroup (SocketAddress mcastaddr , NetworkInterface netIf )
255255 throws IOException {
256- if (mcastaddr == null || !(mcastaddr instanceof InetSocketAddress ))
256+ if (!(mcastaddr instanceof InetSocketAddress addr ))
257257 throw new IllegalArgumentException ("Unsupported address type" );
258- leave ((( InetSocketAddress ) mcastaddr ) .getAddress (), netIf );
258+ leave (addr .getAddress (), netIf );
259259 }
260260
261261 protected abstract void leave (InetAddress inetaddr , NetworkInterface netIf )
@@ -292,7 +292,7 @@ public void setOption(int optID, Object o) throws SocketException {
292292 * PlainSocketImpl.setOption().
293293 */
294294 case SO_TIMEOUT :
295- if (o == null || !(o instanceof Integer )) {
295+ if (!(o instanceof Integer )) {
296296 throw new SocketException ("bad argument for SO_TIMEOUT" );
297297 }
298298 int tmp = ((Integer ) o ).intValue ();
@@ -301,45 +301,45 @@ public void setOption(int optID, Object o) throws SocketException {
301301 timeout = tmp ;
302302 return ;
303303 case IP_TOS :
304- if (o == null || !(o instanceof Integer )) {
304+ if (!(o instanceof Integer )) {
305305 throw new SocketException ("bad argument for IP_TOS" );
306306 }
307307 trafficClass = ((Integer )o ).intValue ();
308308 break ;
309309 case SO_REUSEADDR :
310- if (o == null || !(o instanceof Boolean )) {
310+ if (!(o instanceof Boolean )) {
311311 throw new SocketException ("bad argument for SO_REUSEADDR" );
312312 }
313313 break ;
314314 case SO_BROADCAST :
315- if (o == null || !(o instanceof Boolean )) {
315+ if (!(o instanceof Boolean )) {
316316 throw new SocketException ("bad argument for SO_BROADCAST" );
317317 }
318318 break ;
319319 case SO_BINDADDR :
320320 throw new SocketException ("Cannot re-bind Socket" );
321321 case SO_RCVBUF :
322322 case SO_SNDBUF :
323- if (o == null || !(o instanceof Integer ) ||
323+ if (!(o instanceof Integer ) ||
324324 ((Integer )o ).intValue () < 0 ) {
325325 throw new SocketException ("bad argument for SO_SNDBUF or " +
326326 "SO_RCVBUF" );
327327 }
328328 break ;
329329 case IP_MULTICAST_IF :
330- if (o == null || !(o instanceof InetAddress ))
330+ if (!(o instanceof InetAddress ))
331331 throw new SocketException ("bad argument for IP_MULTICAST_IF" );
332332 break ;
333333 case IP_MULTICAST_IF2 :
334- if (o == null || !(o instanceof NetworkInterface ))
334+ if (!(o instanceof NetworkInterface ))
335335 throw new SocketException ("bad argument for IP_MULTICAST_IF2" );
336336 break ;
337337 case IP_MULTICAST_LOOP :
338- if (o == null || !(o instanceof Boolean ))
338+ if (!(o instanceof Boolean ))
339339 throw new SocketException ("bad argument for IP_MULTICAST_LOOP" );
340340 break ;
341341 case SO_REUSEPORT :
342- if (o == null || !(o instanceof Boolean )) {
342+ if (!(o instanceof Boolean )) {
343343 throw new SocketException ("bad argument for SO_REUSEPORT" );
344344 }
345345 if (!supportedOptions ().contains (StandardSocketOptions .SO_REUSEPORT )) {
0 commit comments