From 5583c77f82ebb208ffce525828d096d61c1fa5ee Mon Sep 17 00:00:00 2001 From: MF-KYJKVZUPVATJ Date: Tue, 23 Jan 2024 14:23:09 +0200 Subject: [PATCH 1/2] check if the exception key does not have an empty value --- .../io/cloudslang/lang/runtime/steps/ActionExecutionData.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ActionExecutionData.java b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ActionExecutionData.java index 0497e83951..edcbb4d5ab 100644 --- a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ActionExecutionData.java +++ b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ActionExecutionData.java @@ -210,7 +210,9 @@ private Map runJavaAction(Map } final Serializable exception = returnMap.get(EXCEPTION); - if (exception != null) { + // some java actions contain the exception key without having an actual exception + // this is because some actions have the output field named as "errorMessage", others "exception" + if (exception != null && StringUtils.isNotEmpty(exception.toString())) { logException(exception.toString()); } From 4bde3c8619caa25e690a112b1879d973e9b7fa2b Mon Sep 17 00:00:00 2001 From: MF-KYJKVZUPVATJ Date: Tue, 23 Jan 2024 14:34:36 +0200 Subject: [PATCH 2/2] refactor to avoid double null check && double toString method call --- .../lang/runtime/steps/ActionExecutionData.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ActionExecutionData.java b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ActionExecutionData.java index edcbb4d5ab..90b2dddaf3 100644 --- a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ActionExecutionData.java +++ b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ActionExecutionData.java @@ -210,10 +210,13 @@ private Map runJavaAction(Map } final Serializable exception = returnMap.get(EXCEPTION); - // some java actions contain the exception key without having an actual exception - // this is because some actions have the output field named as "errorMessage", others "exception" - if (exception != null && StringUtils.isNotEmpty(exception.toString())) { - logException(exception.toString()); + if (exception != null) { + // some java actions contain the exception key without having an actual exception + // this is because some actions have the output field named as "errorMessage", others "exception" + String exceptionMessage = exception.toString(); + if (!exceptionMessage.isEmpty()) { + logException(exceptionMessage); + } } return handleSensitiveValues(returnMap, currentContext);