Browse Source

Code review updates

pull/6882/head
Volodymyr Babak 4 years ago
parent
commit
a35f8b9a38
  1. 15
      application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java

15
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<TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse>>() { Futures.addCallback(future, new FutureCallback<TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse>>() {
@Override @Override
public void onSuccess(@Nullable TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse> result) { public void onSuccess(@Nullable TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse> result) {
if (result == null) { if (result != null) {
queueInvokeMsgs.incrementAndGet();
} else {
JsInvokeProtos.JsInvokeResponse invokeResponse = result.getValue().getInvokeResponse(); JsInvokeProtos.JsInvokeResponse invokeResponse = result.getValue().getInvokeResponse();
if (invokeResponse.getSuccess()) { if (invokeResponse.getSuccess()) {
queueInvokeMsgs.incrementAndGet(); queueInvokeMsgs.incrementAndGet();
} else { } else {
JsInvokeProtos.JsInvokeErrorCode errorCode = invokeResponse.getErrorCode(); JsInvokeProtos.JsInvokeErrorCode errorCode = invokeResponse.getErrorCode();
final RuntimeException e = new RuntimeException(invokeResponse.getErrorDetails()); final RuntimeException e = new RuntimeException(invokeResponse.getErrorDetails());
onScriptExecutionError(scriptId, e, scriptBody);
if (JsInvokeProtos.JsInvokeErrorCode.TIMEOUT_ERROR.equals(errorCode)) { if (JsInvokeProtos.JsInvokeErrorCode.TIMEOUT_ERROR.equals(errorCode)) {
onScriptExecutionError(scriptId, e, scriptBody);
queueTimeoutMsgs.incrementAndGet(); queueTimeoutMsgs.incrementAndGet();
queueFailedMsgs.incrementAndGet(); } else if (JsInvokeProtos.JsInvokeErrorCode.COMPILATION_ERROR.equals(errorCode)) {
} else if (JsInvokeProtos.JsInvokeErrorCode.COMPILATION_ERROR.equals(errorCode) onScriptExecutionError(scriptId, e, scriptBody);
|| JsInvokeProtos.JsInvokeErrorCode.RUNTIME_ERROR.equals(errorCode)) {
queueFailedMsgs.incrementAndGet();
} }
queueFailedMsgs.incrementAndGet();
} }
} }
} }
@ -217,8 +214,6 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService {
public void onFailure(Throwable t) { public void onFailure(Throwable t) {
if (t instanceof TimeoutException || (t.getCause() != null && t.getCause() instanceof TimeoutException)) { if (t instanceof TimeoutException || (t.getCause() != null && t.getCause() instanceof TimeoutException)) {
queueTimeoutMsgs.incrementAndGet(); queueTimeoutMsgs.incrementAndGet();
} else {
onScriptExecutionError(scriptId, t, scriptBody);
} }
queueFailedMsgs.incrementAndGet(); queueFailedMsgs.incrementAndGet();
} }

Loading…
Cancel
Save