Access RemoteAddress exactly once
[netconf.git] / 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