From 162aeeb5ea5b6bd1ec946ddce7c2015002893d7a Mon Sep 17 00:00:00 2001 From: Christian Wohlert Date: Mon, 26 Jan 2026 16:08:53 +0100 Subject: [PATCH] netcom: Fix NPE in establishConnection when peer is null Signed-off-by: Christian Wohlert --- .../linbit/linstor/netcom/TcpConnectorService.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/server/src/main/java/com/linbit/linstor/netcom/TcpConnectorService.java b/server/src/main/java/com/linbit/linstor/netcom/TcpConnectorService.java index a9903568c..537a92b8b 100644 --- a/server/src/main/java/com/linbit/linstor/netcom/TcpConnectorService.java +++ b/server/src/main/java/com/linbit/linstor/netcom/TcpConnectorService.java @@ -997,7 +997,7 @@ protected void establishConnection(SelectionKey currentKey) String localAddrText = null; String remoteAddrText = null; - try + if (localAddr instanceof InetSocketAddress) { final InetSocketAddress localInetAddr = (InetSocketAddress) localAddr; final InetAddress ipAddress = localInetAddr.getAddress(); @@ -1006,12 +1006,8 @@ protected void establishConnection(SelectionKey currentKey) localAddrText = ipAddress.getHostAddress(); } } - catch (ClassCastException ignored) - { - // ignored - } - try + if (remoteAddr instanceof InetSocketAddress) { final InetSocketAddress remoteInetAddr = (InetSocketAddress) remoteAddr; final InetAddress ipAddress = remoteInetAddr.getAddress(); @@ -1020,10 +1016,6 @@ protected void establishConnection(SelectionKey currentKey) remoteAddrText = ipAddress.getHostAddress(); } } - catch (ClassCastException ignored) - { - // ignored - } final String errorDescription = this.getServiceName() + " connector: Connection " +