You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ck...@apache.org on 2019/12/30 19:04:26 UTC
[logging-log4j2] branch release-2.x updated: LOG4J2-2751: Avoid
unnecessary throw/catch in StackLocator.getCallerClass
This is an automated email from the ASF dual-hosted git repository.
ckozak pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/release-2.x by this push:
new 80360db LOG4J2-2751: Avoid unnecessary throw/catch in StackLocator.getCallerClass
80360db is described below
commit 80360db49acc192eee631006349f37fae469d061
Author: Carter Kozak <ck...@ckozak.net>
AuthorDate: Mon Dec 30 14:03:10 2019 -0500
LOG4J2-2751: Avoid unnecessary throw/catch in StackLocator.getCallerClass
This issue only impacted environments where Reflection.getCallerClass is
not accessible.
---
.../src/main/java/org/apache/logging/log4j/util/StackLocator.java | 3 +++
src/changes/changes.xml | 3 +++
2 files changed, 6 insertions(+)
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/StackLocator.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/StackLocator.java
index 5ac08a0..7841e0d 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/StackLocator.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/StackLocator.java
@@ -104,6 +104,9 @@ public final class StackLocator {
if (depth < 0) {
throw new IndexOutOfBoundsException(Integer.toString(depth));
}
+ if (GET_CALLER_CLASS == null) {
+ return null;
+ }
// note that we need to add 1 to the depth value to compensate for this method, but not for the Method.invoke
// since Reflection.getCallerClass ignores the call to Method.invoke()
try {
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 14f801a..4fd62ca 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,9 @@
<action issue="LOG4J2-2735" dev="ckozak" type="fix" due-to="Andy Wilkinson">
PluginCache output is reproducible allowing the annotation processor to produce deterministic results.
</action>
+ <action issue="LOG4J2-2751" dev="ckozak" type="fix">
+ Fix StackLocator.getCallerClass performance in cases where Reflection.getCallerClass is not accessible.
+ </action>
</release>
<release version="2.13.0" date="2019-12-11" description="GA Release 2.13.0">
<action issue="LOG4J2-2058" dev="rgoers" type="fix">