Access RemoteAddress exactly once 48/110048/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 27 Jan 2024 20:49:22 +0000 (21:49 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 27 Jan 2024 20:49:22 +0000 (21:49 +0100)
We are using the value twice, so let's save it in a local variable.

Change-Id: Ib38a12a3ee71199cbdf8e118225225d2c4ada6f6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountService.java

index cf2af212420e1a05b676069679193af96d82410e..9086c978e7263bcfe934241d4ff825e7e6783932 100644 (file)
@@ -211,10 +211,11 @@ public final class CallHomeMountService implements AutoCloseable {
         return new CallHomeSshSessionContextManager() {
             @Override
             public CallHomeSshSessionContext createContext(final String id, final ClientSession clientSession) {
-                topology.enableNode(asNode(id, clientSession.getRemoteAddress(), SSH_PROTOCOL));
+                final var remoteAddr = clientSession.getRemoteAddress();
+                topology.enableNode(asNode(id, remoteAddr, SSH_PROTOCOL));
                 final var netconfLayer = netconfLayerMapping.remove(id);
-                return netconfLayer == null ? null : new CallHomeSshSessionContext(id, clientSession.getRemoteAddress(),
-                    clientSession, netconfLayer.sessionListener, netconfLayer.netconfSessionFuture);
+                return netconfLayer == null ? null : new CallHomeSshSessionContext(id, remoteAddr, clientSession,
+                    netconfLayer.sessionListener, netconfLayer.netconfSessionFuture);
             }
 
             @Override