From bcb088ff848d235743650779625598e224b29307 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 4 Jul 2022 22:31:12 +0200 Subject: [PATCH] Use instanceof pattern in RemoteNetconfCommand Remove duplicate casts, improving expressiveness. Change-Id: I662686d163217a28d8d1c2d44e8ad1f7c3a7de4f Signed-off-by: Robert Varga --- .../org/opendaylight/netconf/ssh/RemoteNetconfCommand.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netconf/mdsal-netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/RemoteNetconfCommand.java b/netconf/mdsal-netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/RemoteNetconfCommand.java index d9ef852404..de2251f6a0 100644 --- a/netconf/mdsal-netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/RemoteNetconfCommand.java +++ b/netconf/mdsal-netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/RemoteNetconfCommand.java @@ -108,9 +108,9 @@ public class RemoteNetconfCommand implements AsyncCommand { final SocketAddress remoteAddress = session.getIoSession().getRemoteAddress(); final String hostName; final String port; - if (remoteAddress instanceof InetSocketAddress) { - hostName = ((InetSocketAddress) remoteAddress).getAddress().getHostAddress(); - port = Integer.toString(((InetSocketAddress) remoteAddress).getPort()); + if (remoteAddress instanceof InetSocketAddress remoteInetAddress) { + hostName = remoteInetAddress.getAddress().getHostAddress(); + port = Integer.toString(remoteInetAddress.getPort()); } else { hostName = ""; port = ""; -- 2.36.6