diff --git a/java/org/apache/tomcat/util/log/SystemLogHandler.java b/java/org/apache/tomcat/util/log/SystemLogHandler.java
index 2293f349afaa..946d9d6d9bfc 100644
--- a/java/org/apache/tomcat/util/log/SystemLogHandler.java
+++ b/java/org/apache/tomcat/util/log/SystemLogHandler.java
@@ -20,7 +20,7 @@
import java.io.PrintStream;
import java.util.ArrayDeque;
import java.util.Deque;
-import java.util.EmptyStackException;
+import java.util.NoSuchElementException;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -83,7 +83,7 @@ public static void startCapture() {
if (!reuse.isEmpty()) {
try {
log = reuse.remove();
- } catch (EmptyStackException e) {
+ } catch (NoSuchElementException e) {
log = new CaptureLog();
}
} else {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 6754b87f3389..bd62a89331e3 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -112,6 +112,11 @@
use of fully qualified class names in 10.1.14 that broke the jdbc-pool.
(markt)
+
+ 66331: Fix a regression in refactoring for Stack
+ on the SystemLogHandler
which caught incorrect exception.
+ (lihan)
+