From 9e3d79bedeee494d24bdb03cc598bae5184a3abf Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Sun, 10 Dec 2023 12:40:50 +0100 Subject: [PATCH] Fixed NPE in debug log --- .../http/impl/io/PoolingHttpClientConnectionManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java index 105cbc88a..7e816909a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java @@ -409,7 +409,11 @@ public class PoolingHttpClientConnectionManager } } else { if (LOG.isDebugEnabled()) { - LOG.debug("{} connection is not kept alive(isConsistent:{})", ConnPoolSupport.getId(endpoint), conn.isConsistent()); + if (conn != null && !conn.isConsistent()) { + LOG.debug("{} connection is in an inconsistent state and cannot be kept alive)", ConnPoolSupport.getId(endpoint)); + } else { + LOG.debug("{} connection is not kept alive)", ConnPoolSupport.getId(endpoint)); + } } } } catch (final RuntimeException ex) {