You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2020/03/28 17:28:58 UTC

[logging-log4j2] branch release-2.x updated (54e96e5 -> abd83e6)

This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a change to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git.


    from 54e96e5  LOG4J2-2807 - Add EventLookup to retrieve fields from the log event
     new d5f1a25  avoid NPE because the stacklocator returned null (#356)
     new abd83e6  Avoid NullPointerException when StackWalker returns null.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../main/java/org/apache/logging/log4j/util/StackLocator.java    | 3 ++-
 .../java/org/apache/logging/log4j/util/StackLocatorTest.java     | 9 ++++++++-
 src/changes/changes.xml                                          | 3 +++
 3 files changed, 13 insertions(+), 2 deletions(-)


[logging-log4j2] 01/02: avoid NPE because the stacklocator returned null (#356)

Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit d5f1a25d2b7775c5e83c3c7652e26147087eaffd
Author: Romain Manni-Bucau <rm...@gmail.com>
AuthorDate: Sat Mar 28 17:58:04 2020 +0100

    avoid NPE because the stacklocator returned null (#356)
---
 .../main/java/org/apache/logging/log4j/util/StackLocator.java    | 3 ++-
 .../java/org/apache/logging/log4j/util/StackLocatorTest.java     | 9 ++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/StackLocator.java b/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/StackLocator.java
index 1eec813..12e4e2a 100644
--- a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/StackLocator.java
+++ b/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/StackLocator.java
@@ -76,7 +76,8 @@ public class StackLocator {
 
     public StackTraceElement calcLocation(final String fqcnOfLogger) {
         FQCN.set(fqcnOfLogger);
-        StackTraceElement element = walker.walk(LOCATOR).toStackTraceElement();
+        final StackWalker.StackFrame walk = walker.walk(LOCATOR);
+        final StackTraceElement element = walk == null ? null : walk.toStackTraceElement();
         FQCN.set(null);
         return element;
     }
diff --git a/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/StackLocatorTest.java b/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/StackLocatorTest.java
index 77396c9..bf76fc0 100644
--- a/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/StackLocatorTest.java
+++ b/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/StackLocatorTest.java
@@ -26,6 +26,7 @@ import java.util.Stack;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 
 @RunWith(BlockJUnit4ClassRunner.class)
@@ -132,7 +133,13 @@ public class StackLocatorTest {
          */
         final StackTraceElement element = new Foo().foo();
         assertEquals("org.apache.logging.log4j.util.StackLocatorTest$Foo", element.getClassName());
-        assertEquals(100, element.getLineNumber());
+        assertEquals(101, element.getLineNumber());
+    }
+
+    @Test
+    public void testCalcLocationWhenNotInTheStack() {
+        final StackTraceElement stackTraceElement = stackLocator.calcLocation("java.util.Logger");
+        assertNull(stackTraceElement);
     }
 
     class ClassLocator {


[logging-log4j2] 02/02: Avoid NullPointerException when StackWalker returns null.

Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit abd83e6eb8c6f4613ce42a7c630a694a218fa8c2
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Sat Mar 28 10:02:58 2020 -0700

    Avoid NullPointerException when StackWalker returns null.
---
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 0c74936..ea39481 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -30,6 +30,9 @@
          - "remove" - Removed
     -->
     <release version="2.13.2" date="2020-MM-DD" description="GA Release 2.13.2">
+      <action issue="LOG4J2-2809" dev="rgoers" type="fix" due-to="Romain Manni-Bucau">
+        Avoid NullPointerException when StackWalker returns null.
+      </action>
       <action issue="LOG4J2-2807" dev="rgoers" type="add">
         Added EventLookup to retrieve fields from the log event.
       </action>