From a401f812b8ca7f6da1f36ebd8ec0505d073f711a Mon Sep 17 00:00:00 2001 From: Mohab Mohie Date: Fri, 22 Mar 2024 22:51:34 +0200 Subject: [PATCH] handle stringbuilder to avoid exception (#1544) --- .../com/shaft/tools/io/internal/ReportManagerHelper.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/shaft/tools/io/internal/ReportManagerHelper.java b/src/main/java/com/shaft/tools/io/internal/ReportManagerHelper.java index 61813049fea..2cb881061ee 100644 --- a/src/main/java/com/shaft/tools/io/internal/ReportManagerHelper.java +++ b/src/main/java/com/shaft/tools/io/internal/ReportManagerHelper.java @@ -623,9 +623,12 @@ public static void log(String logText, List> attachments) { if (attachments != null && !attachments.isEmpty() && (attachments.size() > 1 || (attachments.getFirst() != null && !attachments.getFirst().isEmpty()))) { attachments.forEach(attachment -> { if (attachment != null && !attachment.isEmpty()) { - if (attachment.get(2) instanceof String) { + if (attachment.get(2) instanceof String string) { attachAsStep(attachment.get(0).toString(), attachment.get(1).toString(), - new ByteArrayInputStream(attachment.get(2).toString().getBytes())); + new ByteArrayInputStream(string.getBytes())); + } else if (attachment.get(2) instanceof StringBuilder stringBuilder) { + attachAsStep(attachment.get(0).toString(), attachment.get(1).toString(), + new ByteArrayInputStream(stringBuilder.toString().getBytes())); } else { attachAsStep(attachment.get(0).toString(), attachment.get(1).toString(), (InputStream) attachment.get(2));