From 9604e3f28e7c318729520f8861ecec20a8f743f3 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 27 Jan 2024 21:49:22 +0100 Subject: [PATCH] Access RemoteAddress exactly once We are using the value twice, so let's save it in a local variable. Change-Id: Ib38a12a3ee71199cbdf8e118225225d2c4ada6f6 Signed-off-by: Robert Varga --- .../netconf/callhome/mount/CallHomeMountService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountService.java b/apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountService.java index cf2af21242..9086c978e7 100644 --- a/apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountService.java +++ b/apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountService.java @@ -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 -- 2.36.6