From e7b172faade7b10952f62644702eddbb710af4ec Mon Sep 17 00:00:00 2001 From: Christian Femers Date: Tue, 23 Mar 2021 09:20:13 +0100 Subject: [PATCH] Fix missing usages of MessageTransformer for Throwable sanitization --- .../internal/sanitization/MultipleFailuresErrorSanitizer.java | 2 +- .../api/internal/sanitization/SafeTypeThrowableSanitizer.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/tum/in/test/api/internal/sanitization/MultipleFailuresErrorSanitizer.java b/src/main/java/de/tum/in/test/api/internal/sanitization/MultipleFailuresErrorSanitizer.java index 9a8b4ff9..94684f32 100644 --- a/src/main/java/de/tum/in/test/api/internal/sanitization/MultipleFailuresErrorSanitizer.java +++ b/src/main/java/de/tum/in/test/api/internal/sanitization/MultipleFailuresErrorSanitizer.java @@ -30,7 +30,7 @@ public Throwable sanitize(Throwable t, MessageTransformer messageTransformer) { * So we just pass the message constructed be the old object, as the new object * will in absence of failures only return the heading. */ - MultipleFailuresError newMfe = createNewInstance(mfe, info.getMessage(), List.of()); + MultipleFailuresError newMfe = createNewInstance(mfe, messageTransformer.apply(info), List.of()); SanitizationUtils.copyThrowableInfoSafe(info, newMfe); // Retain failure information in the suppressed Throwables for (Throwable failure : failures) diff --git a/src/main/java/de/tum/in/test/api/internal/sanitization/SafeTypeThrowableSanitizer.java b/src/main/java/de/tum/in/test/api/internal/sanitization/SafeTypeThrowableSanitizer.java index 462d9ee4..ba7bf13a 100644 --- a/src/main/java/de/tum/in/test/api/internal/sanitization/SafeTypeThrowableSanitizer.java +++ b/src/main/java/de/tum/in/test/api/internal/sanitization/SafeTypeThrowableSanitizer.java @@ -68,6 +68,7 @@ public Throwable sanitize(Throwable t, MessageTransformer messageTransformer) { // this is OK because we are only dealing with safe types here ThrowableInfo info = ThrowableInfo.of(type, ThrowableUtils.retrievePropertyValues(t)); info.sanitize(ThrowableUtils.PROPERTY_SANITIZER); + info.setMessage(messageTransformer.apply(info)); var throwableCreator = cachedThrowableCreators.computeIfAbsent(type, this::findThrowableCreator); try { Throwable newInstance = throwableCreator.create(info);