Skip to content

Commit

Permalink
#11792 handle review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Orban <[email protected]>
  • Loading branch information
lorban committed May 15, 2024
1 parent ffb8e8d commit 619e344
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
package org.eclipse.jetty.logging;

import java.io.PrintStream;
import java.util.HashSet;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Objects;
import java.util.Set;
import java.util.TimeZone;
Expand Down Expand Up @@ -177,7 +178,7 @@ private void format(StringBuilder builder, JettyLogger logger, Level level, long
}
else
{
appendCause(builder, new HashSet<>(), cause, "");
appendCause(builder, cause, "", Collections.newSetFromMap(new IdentityHashMap<>()));
}
}
}
Expand All @@ -201,12 +202,12 @@ private String renderedLevel(Level level)
}
}

private void appendCause(StringBuilder builder, Set<Throwable> visited, Throwable cause, String indent)
private void appendCause(StringBuilder builder, Throwable cause, String indent, Set<Throwable> visited)
{
builder.append(EOL).append(indent);
if (visited.contains(cause))
{
builder.append("[CIRCULAR REFERENCE: ").append(cause.getClass().getName()).append("]");
builder.append("[CIRCULAR REFERENCE: ").append(cause).append("]");
return;
}
visited.add(cause);
Expand All @@ -222,14 +223,14 @@ private void appendCause(StringBuilder builder, Set<Throwable> visited, Throwabl
for (Throwable suppressed : cause.getSuppressed())
{
builder.append(EOL).append(indent).append("Suppressed: ");
appendCause(builder, visited, suppressed, "\t|" + indent);
appendCause(builder, suppressed, "\t|" + indent, visited);
}

Throwable by = cause.getCause();
if (by != null && by != cause)
{
builder.append(EOL).append(indent).append("Caused by: ");
appendCause(builder, visited, by, indent);
appendCause(builder, by, indent, visited);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void testCircularThrowable()

appender.emit(logger, Level.INFO, System.currentTimeMillis(), "tname", thrown, "the message");

output.assertContains("[CIRCULAR REFERENCE: java.lang.Throwable]");
output.assertContains("CIRCULAR REFERENCE");
}

@Test
Expand Down

0 comments on commit 619e344

Please sign in to comment.