From 3b1a99543dd2637fc093e1b41ee54f14ff307d9f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bempel Date: Mon, 7 Sep 2026 15:42:29 +0200 Subject: [PATCH] Avoid Throwable::toString in ExceptionReplay Calling Throwable::toString is dangerous because it can be overriden. so instead of logging the toString of an exception we are using the class name --- .../debugger/exception/AbstractExceptionDebugger.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/exception/AbstractExceptionDebugger.java b/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/exception/AbstractExceptionDebugger.java index 56ae15c44cc..eb8abc565de 100644 --- a/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/exception/AbstractExceptionDebugger.java +++ b/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/exception/AbstractExceptionDebugger.java @@ -55,7 +55,7 @@ public abstract class AbstractExceptionDebugger implements DebuggerContext.Excep public void handleException(Throwable t, AgentSpan span) { if (!shouldHandleException(t, span)) { if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Skip handling exception: {}", t.toString()); + LOGGER.debug("Skip handling exception: {}", t.getClass().getTypeName()); } return; } @@ -75,7 +75,8 @@ public void handleException(Throwable t, AgentSpan span) { ExceptionProbeManager.ThrowableState state = exceptionProbeManager.getStateByThrowable(innerMostException); if (state == null) { - LOGGER.debug("Unable to find state for throwable: {}", innerMostException.toString()); + LOGGER.debug( + "Unable to find state for throwable: {}", innerMostException.getClass().getTypeName()); return; } processSnapshotsAndSetTags(