diff --git a/src/main/java/org/jboss/logmanager/formatters/StructuredFormatter.java b/src/main/java/org/jboss/logmanager/formatters/StructuredFormatter.java index d83b5ad8..562ccba2 100644 --- a/src/main/java/org/jboss/logmanager/formatters/StructuredFormatter.java +++ b/src/main/java/org/jboss/logmanager/formatters/StructuredFormatter.java @@ -19,7 +19,6 @@ package org.jboss.logmanager.formatters; -import java.io.PrintWriter; import java.io.Writer; import java.time.Instant; import java.time.ZoneId; @@ -248,9 +247,9 @@ public final synchronized String format(final ExtLogRecord record) { } if (isFormattedExceptionOutputType()) { - final StringBuilderWriter w = new StringBuilderWriter(); - thrown.printStackTrace(new PrintWriter(w)); - generator.add(getKey(Key.STACK_TRACE), w.toString()); + final StringBuilder sb = new StringBuilder(); + StackTraceFormatter.renderStackTrace(sb, thrown, false, -1); + generator.add(getKey(Key.STACK_TRACE), sb.toString()); } } if (details) { diff --git a/src/test/java/org/jboss/logmanager/formatters/StackTraceFormatterTests.java b/src/test/java/org/jboss/logmanager/formatters/StackTraceFormatterTests.java index d7f2facd..47afab6b 100644 --- a/src/test/java/org/jboss/logmanager/formatters/StackTraceFormatterTests.java +++ b/src/test/java/org/jboss/logmanager/formatters/StackTraceFormatterTests.java @@ -23,6 +23,7 @@ import java.io.StringWriter; import org.junit.Assert; +import org.junit.Assume; import org.junit.Test; /** @@ -30,6 +31,8 @@ */ public class StackTraceFormatterTests { + private static final boolean IS_IBM_JDK = System.getProperty("java.vendor").startsWith("IBM"); + @Test public void compareSimpleStackTrace() { final RuntimeException e = new RuntimeException(); @@ -57,6 +60,7 @@ public void compareCauseStackTrace() { @Test public void compareSuppressedAndCauseStackTrace() { + Assume.assumeFalse("The IBM JDK does not show print circular references.", IS_IBM_JDK); final RuntimeException r1 = new RuntimeException("Exception 1"); final RuntimeException r2 = new RuntimeException("Exception 2", r1); final RuntimeException r3 = new RuntimeException("Exception 3", r2); @@ -76,6 +80,7 @@ public void compareSuppressedAndCauseStackTrace() { @Test public void compareNestedSuppressedStackTrace() { + Assume.assumeFalse("The IBM JDK does not show print circular references.", IS_IBM_JDK); final RuntimeException r1 = new RuntimeException("Exception 1"); final RuntimeException r2 = new RuntimeException("Exception 2", r1); final RuntimeException r3 = new RuntimeException("Exception 3", r2); @@ -99,6 +104,7 @@ public void compareNestedSuppressedStackTrace() { @Test public void compareMultiNestedSuppressedStackTrace() { + Assume.assumeFalse("The IBM JDK does not show print circular references.", IS_IBM_JDK); final Throwable cause = createMultiNestedCause(); final StringWriter writer = new StringWriter(); @@ -112,6 +118,7 @@ public void compareMultiNestedSuppressedStackTrace() { @Test public void compareMultiNestedSuppressedAndNestedCauseStackTrace() { + Assume.assumeFalse("The IBM JDK does not show print circular references.", IS_IBM_JDK); final Throwable rootCause = createMultiNestedCause(); final RuntimeException cause = new RuntimeException("This is the parent", rootCause);