You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Sam Braam (JIRA)" <ji...@apache.org> on 2015/06/24 06:55:42 UTC

[jira] [Closed] (LOG4J2-1067) ThrowableProxy getExtendedStackTraceAsString throws NPE on deserialized nested exceptions

     [ https://issues.apache.org/jira/browse/LOG4J2-1067?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sam Braam closed LOG4J2-1067.
-----------------------------

Looks good, thanks for the quick response.

Sam

> 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