From 4bde3c8619caa25e690a112b1879d973e9b7fa2b Mon Sep 17 00:00:00 2001 From: MF-KYJKVZUPVATJ Date: Tue, 23 Jan 2024 14:34:36 +0200 Subject: [PATCH] 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 edcbb4d5a..90b2dddaf 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);