logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (LOG4J2-1067) ThrowableProxy getExtendedStackTraceAsString throws NPE on deserialized nested exceptions
Date Tue, 23 Jun 2015 16:18:00 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-1067?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14597878#comment-14597878
] 

Gary Gregory edited comment on LOG4J2-1067 at 6/23/15 4:17 PM:
---------------------------------------------------------------

Sam,

Thank you for your report and patch.

I applied the patch to Git master with refactored and additional tests. 

Please verify and close.

More reports are welcome!

Gary


was (Author: garydgregory):
Sam,

Thank you for your report and patch.

I applied the patch to Git master with refactored and additional tests. 

Please verify and close.

More reports are welcome!

> ThrowableProxy getExtendedStackTraceAsString throws NPE on deserialized nested exceptions
> -----------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-1067
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1067
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.3
>            Reporter: Sam Braam
>            Priority: Minor
>             Fix For: 2.4
>
>
> In a similar vein to LOG4J2-914, I also am attempting to use log4j as a daemon log server.
 The fix for LOG4J2-914 only solved the NPE problem for one dimensional exceptions. Nested
exceptions also cause an NPE in the current implementation.  Here is a test/patch diff for
the bug:
> {code}
> ---
>  .../org/apache/logging/log4j/core/impl/ThrowableProxy.java     |  2 +-
>  .../org/apache/logging/log4j/core/impl/ThrowableProxyTest.java | 10 ++++++++++
>  2 files changed, 11 insertions(+), 1 deletion(-)
> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java
> index 67d55ec..307de58 100644
> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java
> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java
> @@ -207,7 +207,7 @@ public class ThrowableProxy implements Serializable {
>              return;
>          }
>          sb.append("Caused by: ").append(cause).append(EOL);
> -        this.formatElements(sb, cause.commonElementCount, cause.getThrowable().getStackTrace(),
> +        this.formatElements(sb, cause.commonElementCount, cause.getStackTrace(),
>                  cause.extendedStackTrace, ignorePackages);
>          this.formatCause(sb, cause.causeProxy, ignorePackages);
>      }
> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java
b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java
> index 7019aa2..6eb5dbc 100644
> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java
> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java
> @@ -146,6 +146,16 @@ public class ThrowableProxyTest {
>  
>          assertEquals(proxy.getExtendedStackTraceAsString(), proxy2.getExtendedStackTraceAsString());
>      }
> +    
> +    @Test
> +    public void testSerialization_getExtendedStackTraceAsStringWithNestedThrowable()
throws Exception {
> +        final Throwable throwable = new RuntimeException(new IllegalArgumentException("This
is a test"));
> +        final ThrowableProxy proxy = new ThrowableProxy(throwable);
> +        final byte[] binary = serialize(proxy);
> +        final ThrowableProxy proxy2 = deserialize(binary);
> +
> +        assertEquals(proxy.getExtendedStackTraceAsString(), proxy2.getExtendedStackTraceAsString());
> +    }
>  
>      @Test
>      public void testSerializationWithUnknownThrowable() throws Exception {
> -- 
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message