From 686b0a17ea65ef206df00d50938d16d854a4da15 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 20 Sep 2023 09:58:19 -0400 Subject: [PATCH] Avoid rare NPE in DefaultPooledObject.toString() --- .../org/apache/commons/pool3/impl/DefaultPooledObject.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/pool3/impl/DefaultPooledObject.java b/src/main/java/org/apache/commons/pool3/impl/DefaultPooledObject.java index c46f8664e..504401e35 100644 --- a/src/main/java/org/apache/commons/pool3/impl/DefaultPooledObject.java +++ b/src/main/java/org/apache/commons/pool3/impl/DefaultPooledObject.java @@ -21,6 +21,7 @@ import java.time.Duration; import java.time.Instant; import java.util.Deque; +import java.util.Objects; import org.apache.commons.pool3.PooledObject; import org.apache.commons.pool3.PooledObjectState; @@ -280,7 +281,7 @@ public synchronized boolean startEvictionTest() { public String toString() { final StringBuilder result = new StringBuilder(); result.append("Object: "); - result.append(object.toString()); + result.append(Objects.toString(object)); result.append(", State: "); synchronized (this) { result.append(state.toString());