From a35f8b9a380ece27344b15878ebe4aae53d3eed7 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Tue, 5 Jul 2022 17:41:54 +0300 Subject: [PATCH] Code review updates --- .../service/script/RemoteJsInvokeService.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java index 27ee22e459..3fda3df46e 100644 --- a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java +++ b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java @@ -192,23 +192,20 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { Futures.addCallback(future, new FutureCallback>() { @Override public void onSuccess(@Nullable TbProtoQueueMsg result) { - if (result == null) { - queueInvokeMsgs.incrementAndGet(); - } else { + if (result != null) { JsInvokeProtos.JsInvokeResponse invokeResponse = result.getValue().getInvokeResponse(); if (invokeResponse.getSuccess()) { queueInvokeMsgs.incrementAndGet(); } else { JsInvokeProtos.JsInvokeErrorCode errorCode = invokeResponse.getErrorCode(); final RuntimeException e = new RuntimeException(invokeResponse.getErrorDetails()); - onScriptExecutionError(scriptId, e, scriptBody); if (JsInvokeProtos.JsInvokeErrorCode.TIMEOUT_ERROR.equals(errorCode)) { + onScriptExecutionError(scriptId, e, scriptBody); queueTimeoutMsgs.incrementAndGet(); - queueFailedMsgs.incrementAndGet(); - } else if (JsInvokeProtos.JsInvokeErrorCode.COMPILATION_ERROR.equals(errorCode) - || JsInvokeProtos.JsInvokeErrorCode.RUNTIME_ERROR.equals(errorCode)) { - queueFailedMsgs.incrementAndGet(); + } else if (JsInvokeProtos.JsInvokeErrorCode.COMPILATION_ERROR.equals(errorCode)) { + onScriptExecutionError(scriptId, e, scriptBody); } + queueFailedMsgs.incrementAndGet(); } } } @@ -217,8 +214,6 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { public void onFailure(Throwable t) { if (t instanceof TimeoutException || (t.getCause() != null && t.getCause() instanceof TimeoutException)) { queueTimeoutMsgs.incrementAndGet(); - } else { - onScriptExecutionError(scriptId, t, scriptBody); } queueFailedMsgs.incrementAndGet(); }