ppkarwasz commented on code in PR #1214:
URL: https://github.com/apache/logging-log4j2/pull/1214#discussion_r1073100498


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxyHelper.java:
##########
@@ -85,7 +85,7 @@ static ExtendedStackTraceElement[] toExtendedStackTrace(
             stackLength = stackTrace.length;
         }
         final ExtendedStackTraceElement[] extStackTrace = new 
ExtendedStackTraceElement[stackLength];
-        Class<?> clazz = stack.isEmpty() ? null : stack.peek();
+        Class<?> clazz = stack.isEmpty() ? null : stack.peekLast();

Review Comment:
   Yes, I was referring to the broken slow path, which still uses `push` 
instead of `addLast`.
   
   Also:
   
   * `stack.isEmpty() ? null : stack.peekLast()` can be replaced with 
`stack.peekLast()`,
   * the comment in 
`org.apache.logging.log4j.util.PrivateSecurityManagerStackTraceUtil` states 
_"The size of the Deque is the number of methods on the execution stack. The 
first element is the class that started execution on this thread..."_ and is 
clearly not up-to-date.
   
   Testing the slow path is not easy: you need to create a test named `*IT` 
that has a security manager that does not allow the "createSecurityManager" 
permission. See `EnvironmentPropertySourceSecurityManagerIT` for inspiration.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to