From 18eadf2c2ab8e363851450ad386859c865ed03d2 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 16 Dec 2021 14:31:12 -0600 Subject: [PATCH] Issue #7277 - Fixing NPE from updated getLocalPort Signed-off-by: Joakim Erdfelt --- .../src/main/java/org/eclipse/jetty/server/Request.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index b08c1f71edd9..a60ebc6edfef 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -1044,9 +1044,11 @@ public int getLocalPort() int localPort = _channel.getLocalPort(); if (localPort > 0) return localPort; + InetSocketAddress local = _channel.getLocalAddress(); + if (local != null) + return local.getPort(); } - InetSocketAddress local = _channel.getLocalAddress(); - return local == null ? 0 : local.getPort(); + return 0; } /*