This is an automated email from the ASF dual-hosted git repository.
ckozak pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/master by this push:
new 7c9e306 LOG4J2-2751: Avoid unnecessary throw/catch in
StackLocator.getCallerClass
7c9e306 is described below
commit 7c9e30644f57f6c0d7c4406b87b613bc7502c922
Author: Carter Kozak <[email protected]>
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 3c1308b..7a9c234 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
@@ -102,6 +102,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 71ac223..92222b6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -190,6 +190,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">