You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2023/01/30 19:54:33 UTC
[logging-log4j2] 02/06: This change fixes incorrect behavior of stack elements cache due to a change of data structure from LIFO to FIFO. This bug causes a major performance regression
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 9fdb34f077e1c584b0b5737d03170fa4341667b7
Author: Aliaksei Dubrouski <ad...@linkedin.com>
AuthorDate: Tue Jan 17 10:16:50 2023 -0800
This change fixes incorrect behavior of stack elements cache due to a change of data structure from LIFO to FIFO. This bug causes a major performance regression
---
.../org/apache/logging/log4j/core/impl/ThrowableProxyHelper.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxyHelper.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxyHelper.java
index 66b701447f..a3191d9140 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxyHelper.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxyHelper.java
@@ -85,7 +85,7 @@ class ThrowableProxyHelper {
stackLength = stackTrace.length;
}
final ExtendedStackTraceElement[] extStackTrace = new ExtendedStackTraceElement[stackLength];
- Class<?> clazz = stack.isEmpty() ? null : stack.peek();
+ Class<?> clazz = stack.isEmpty() ? null : stack.peekLast();
ClassLoader lastLoader = null;
for (int i = stackLength - 1; i >= 0; --i) {
final StackTraceElement stackTraceElement = stackTrace[i];
@@ -98,8 +98,8 @@ class ThrowableProxyHelper {
final CacheEntry entry = toCacheEntry(clazz, true);
extClassInfo = entry.element;
lastLoader = entry.loader;
- stack.pop();
- clazz = stack.isEmpty() ? null : stack.peek();
+ stack.pollLast();
+ clazz = stack.isEmpty() ? null : stack.peekLast();
} else {
final CacheEntry cacheEntry = map.get(className);
if (cacheEntry != null) {