From 43851cd3f0236ebf9603ee6f2b297b59c471e98f Mon Sep 17 00:00:00 2001 From: Nikita Mazurenko Date: Fri, 24 Jul 2026 17:08:27 +0300 Subject: [PATCH 1/7] Fix Nashorn Global PropertyMap leak on JS script release --- .../script/NashornJsInvokeServiceTest.java | 85 +++++++++++++++++++ .../script/api/js/NashornJsInvokeService.java | 16 +++- 2 files changed, 97 insertions(+), 4 deletions(-) diff --git a/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java b/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java index 01a5f1b6fc..c76eac8c61 100644 --- a/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java @@ -17,13 +17,17 @@ package org.thingsboard.server.service.script; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import delight.nashornsandbox.NashornSandbox; +import delight.nashornsandbox.NashornSandboxes; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.util.ReflectionTestUtils; import org.thingsboard.common.util.TbStopWatch; +import org.thingsboard.script.api.RuleNodeScriptFactory; import org.thingsboard.script.api.ScriptType; import org.thingsboard.script.api.TbScriptException; import org.thingsboard.script.api.js.NashornJsInvokeService; @@ -31,6 +35,7 @@ import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.controller.AbstractControllerTest; import org.thingsboard.server.dao.service.DaoSqlTest; +import javax.script.ScriptEngine; import javax.script.ScriptException; import java.util.ArrayList; import java.util.List; @@ -222,6 +227,86 @@ class NashornJsInvokeServiceTest extends AbstractControllerTest { }); } + @Test + void whenScriptIsReleased_thenGlobalPropertyIsRemoved() throws Exception { + UUID scriptId = evalScript("return msg;"); + String functionName = "invokeInternal_" + scriptId.toString().replace('-', '_'); + assertThat(evalInEngine("this.hasOwnProperty('" + functionName + "')")).hasToString("true"); + + invokeService.release(scriptId).get(); + + // the property must be deleted, not just set to undefined: an abandoned binding keeps + assertThat(evalInEngine("this.hasOwnProperty('" + functionName + "')")).hasToString("false"); + } + + @Test + void givenIifeWrappedEval_whenInvoking_thenResultIsUnchanged() throws Exception { + UUID scriptId = evalScript("return {doubled: msg.temperature * 2};"); + assertThat(invokeScript(scriptId, "{\"temperature\":21}")).contains("\"doubled\":42"); + } + + @Test + void givenIifeWrappedEval_thenImplicitGlobalStateIsStillSharedBetweenScripts() throws Exception { + UUID writer = evalScript("compatSharedState = 777; return msg;"); + UUID reader = evalScript("return {seen: (typeof compatSharedState === 'undefined') ? null : compatSharedState};"); + invokeScript(writer, "{}"); + assertThat(invokeScript(reader, "{}")).contains("\"seen\":777"); + } + + @Test + void givenIifeWrappedEval_thenCompilationErrorUnchanged() { + String badScript = "var a = 1;\nvar b = 2;\nreturn msg.temperature?.value;"; + + String legacyScript = RuleNodeScriptFactory.generateRuleNodeScript("invokeInternal_legacy", badScript, + "msg", "metadata", "msgType"); + NashornSandbox legacySandbox = NashornSandboxes.create(); + legacySandbox.allowNoBraces(false); + legacySandbox.allowLoadFunctions(true); + legacySandbox.setMaxPreparedStatements(30); + int legacyErrorLine = -1; + try { + legacySandbox.eval(legacyScript); + } catch (ScriptException e) { + legacyErrorLine = e.getLineNumber(); + } + assertThat(legacyErrorLine).isGreaterThan(0); + final int expectedLine = legacyErrorLine; + + assertThatThrownBy(() -> evalScript(badScript)) + .isInstanceOf(ExecutionException.class) + .cause() + .isInstanceOf(TbScriptException.class) + .asInstanceOf(type(TbScriptException.class)) + .satisfies(ex -> { + assertThat(ex.getErrorCode()).isEqualTo(TbScriptException.ErrorCode.COMPILATION); + assertThat(ex.getBody()).contains(badScript); + assertThat(ex.getCause()).isInstanceOf(ScriptException.class); + // The IIFE wrapper shifts sandbox-reported line numbers by a constant +2 + // (the beautifier splits the wrapper prefix onto its own lines). Reported + // lines never matched the user's source anyway (the sandbox instrumentation + // already offsets them), so only the small constant shift is tolerated here. + assertThat(((ScriptException) ex.getCause()).getLineNumber()).isBetween(expectedLine, expectedLine + 2); + }); + } + + @Test + void whenInvokingAfterRelease_thenFailsWithNoCompiledScriptFound() throws Exception { + UUID scriptId = evalScript("return msg;"); + invokeScript(scriptId, "{}"); + invokeService.release(scriptId).get(); + assertThatThrownBy(() -> invokeScript(scriptId, "{}")) + .isInstanceOf(ExecutionException.class) + .hasMessageContaining("No compiled script found"); + } + + private Object evalInEngine(String expression) throws Exception { + Object sandbox = ReflectionTestUtils.getField(invokeService, "sandbox"); + if (sandbox != null) { + return ((NashornSandbox) sandbox).eval(expression); + } + return ((ScriptEngine) ReflectionTestUtils.getField(invokeService, "engine")).eval(expression); + } + private void assertThatScriptIsBlocked(UUID scriptId) { assertThatThrownBy(() -> { invokeScript(scriptId, "{}"); diff --git a/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java b/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java index 1ef2eeb6da..bb95c60481 100644 --- a/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java +++ b/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java @@ -140,14 +140,21 @@ public class NashornJsInvokeService extends AbstractJsInvokeService { @Override protected ListenableFuture doEval(UUID scriptId, JsScriptInfo scriptInfo, String jsScript) { + // A top-level function declaration creates a non-configurable property on the Nashorn Global + // that can never be deleted, so every eval/release cycle would grow the Global's PropertyMap + // shape history forever. Declaring the function inside an IIFE and assigning it to a global + // property keeps the property configurable, allowing doRelease() to actually delete it. + // The prefix stays on the first line so that script line numbers in errors are unchanged. + String wrappedScript = "this['" + scriptInfo.getFunctionName() + "'] = (function() { " + jsScript + + "\nreturn " + scriptInfo.getFunctionName() + ";\n})();"; return jsExecutor.submit(() -> { try { evalLock.lock(); try { if (useJsSandbox) { - sandbox.eval(jsScript); + sandbox.eval(wrappedScript); } else { - engine.eval(jsScript); + engine.eval(wrappedScript); } } finally { evalLock.unlock(); @@ -182,10 +189,11 @@ public class NashornJsInvokeService extends AbstractJsInvokeService { } protected void doRelease(UUID scriptId, JsScriptInfo scriptInfo) throws ScriptException { + String deleteScript = "delete this['" + scriptInfo.getFunctionName() + "'];"; if (useJsSandbox) { - sandbox.eval(scriptInfo.getFunctionName() + " = undefined;"); + sandbox.eval(deleteScript); } else { - engine.eval(scriptInfo.getFunctionName() + " = undefined;"); + engine.eval(deleteScript); } } From b67fc8dfb1ad1ca22dc076047f8ee37743b894f2 Mon Sep 17 00:00:00 2001 From: Nikita Mazurenko Date: Fri, 24 Jul 2026 17:08:39 +0300 Subject: [PATCH 2/7] Release EdgeGrpcClient channel on failed connect and guard send/disconnect race --- .../thingsboard/edge/rpc/EdgeGrpcClient.java | 146 +++++++++++------- 1 file changed, 92 insertions(+), 54 deletions(-) diff --git a/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java b/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java index 7e58a2cb9f..f96fe8b38f 100644 --- a/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java +++ b/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java @@ -86,7 +86,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { private StreamObserver inputStream; - private static final ReentrantLock uplinkMsgLock = new ReentrantLock(); + private final ReentrantLock connectionLock = new ReentrantLock(); @Override public void connect(String edgeKey, @@ -127,19 +127,38 @@ public class EdgeGrpcClient implements EdgeRpcClient { .build()); } - channel = builder.build(); - EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel); - log.info("[{}] Sending a connect request to the TB!", edgeKey); - this.inputStream = stub.withCompression("gzip").handleMsgs(initOutputStream(edgeKey, onUplinkResponse, onEdgeUpdate, onDownlink, onError)); - this.inputStream.onNext(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.CONNECT_RPC_MESSAGE) - .setConnectRequestMsg(ConnectRequestMsg.newBuilder() - .setEdgeRoutingKey(edgeKey) - .setEdgeSecret(edgeSecret) - .setEdgeVersion(getNewestEdgeVersion()) - .setMaxInboundMessageSize(maxInboundMessageSize) - .build()) - .build()); + connectionLock.lock(); + try { + channel = builder.build(); + EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel); + log.info("[{}] Sending a connect request to the TB!", edgeKey); + this.inputStream = stub.withCompression("gzip").handleMsgs(initOutputStream(edgeKey, channel, onUplinkResponse, onEdgeUpdate, onDownlink, onError)); + this.inputStream.onNext(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.CONNECT_RPC_MESSAGE) + .setConnectRequestMsg(ConnectRequestMsg.newBuilder() + .setEdgeRoutingKey(edgeKey) + .setEdgeSecret(edgeSecret) + .setEdgeVersion(getNewestEdgeVersion()) + .setMaxInboundMessageSize(maxInboundMessageSize) + .build()) + .build()); + } catch (RuntimeException e) { + // Release the half-built channel, otherwise every failed reconnect attempt leaks + // its event loops and executors, and the next attempt may not recover at all. + log.error("[{}] Failed to establish the connection, shutting down the channel!", edgeKey, e); + if (channel != null) { + try { + channel.shutdownNow(); + } catch (Exception shutdownEx) { + log.error("[{}] Exception during shutdownNow of the failed channel", edgeKey, shutdownEx); + } + } + channel = null; + inputStream = null; + throw e; + } finally { + connectionLock.unlock(); + } } public static EdgeVersion getNewestEdgeVersion() { @@ -147,6 +166,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { } private StreamObserver initOutputStream(String edgeKey, + ManagedChannel streamChannel, Consumer onUplinkResponse, Consumer onEdgeUpdate, Consumer onDownlink, @@ -166,7 +186,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { } else { log.error("[{}] Failed to establish the connection! Code: {}. Error message: {}.", edgeKey, connectResponseMsg.getResponseCode(), connectResponseMsg.getErrorMsg()); try { - EdgeGrpcClient.this.disconnect(true); + EdgeGrpcClient.this.disconnect(true, streamChannel); } catch (InterruptedException e) { log.error("[{}] Got interruption during disconnect!", edgeKey, e); } @@ -188,7 +208,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { public void onError(Throwable t) { log.warn("[{}] Stream was terminated due to error:", edgeKey, t); try { - EdgeGrpcClient.this.disconnect(true); + EdgeGrpcClient.this.disconnect(true, streamChannel); } catch (InterruptedException e) { log.error("[{}] Got interruption during disconnect!", edgeKey, e); } @@ -204,77 +224,95 @@ public class EdgeGrpcClient implements EdgeRpcClient { @Override public void disconnect(boolean onError) throws InterruptedException { - if (!onError) { - try { - if (inputStream != null) { - inputStream.onCompleted(); + disconnect(onError, null); + } + + private void disconnect(boolean onError, ManagedChannel expectedChannel) throws InterruptedException { + ManagedChannel channelToShutdown; + connectionLock.lock(); + try { + // A terminated stream reports its error asynchronously and may lose the race with a + // reconnect: ignore such stale callbacks instead of tearing down the fresh channel. + if (expectedChannel != null && channel != expectedChannel) { + log.info("The channel was already replaced by a reconnect. Skipping disconnect of the stale channel."); + return; + } + if (!onError) { + try { + if (inputStream != null) { + inputStream.onCompleted(); + } + } catch (Exception e) { + log.error("Exception during onCompleted", e); } - } catch (Exception e) { - log.error("Exception during onCompleted", e); } + // Clear the references under the lock so that no send can start against a stream + // whose channel is shutting down - such a write leaks the compressed ByteBuf. + inputStream = null; + channelToShutdown = channel; + channel = null; + } finally { + connectionLock.unlock(); } - if (channel != null) { - channel.shutdown(); + if (channelToShutdown != null) { + channelToShutdown.shutdown(); int attempt = 0; do { try { - channel.awaitTermination(timeoutSecs, TimeUnit.SECONDS); + channelToShutdown.awaitTermination(timeoutSecs, TimeUnit.SECONDS); } catch (Exception e) { log.error("Channel await termination was interrupted", e); } if (attempt > 5) { log.warn("We had reached maximum of termination attempts. Force closing channel"); try { - channel.shutdownNow(); + channelToShutdown.shutdownNow(); } catch (Exception e) { log.error("Exception during shutdownNow", e); } break; } attempt++; - } while (!channel.isTerminated()); + } while (!channelToShutdown.isTerminated()); } } @Override public void sendUplinkMsg(UplinkMsg msg) { - uplinkMsgLock.lock(); - try { - this.inputStream.onNext(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) - .setUplinkMsg(msg) - .build()); - } finally { - uplinkMsgLock.unlock(); - } + sendRequestMsg(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) + .setUplinkMsg(msg) + .build()); } @Override public void sendSyncRequestMsg(boolean fullSyncRequired) { - uplinkMsgLock.lock(); - try { - SyncRequestMsg syncRequestMsg = SyncRequestMsg.newBuilder() - .setFullSync(fullSyncRequired) - .build(); - this.inputStream.onNext(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.SYNC_REQUEST_RPC_MESSAGE) - .setSyncRequestMsg(syncRequestMsg) - .build()); - } finally { - uplinkMsgLock.unlock(); - } + SyncRequestMsg syncRequestMsg = SyncRequestMsg.newBuilder() + .setFullSync(fullSyncRequired) + .build(); + sendRequestMsg(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.SYNC_REQUEST_RPC_MESSAGE) + .setSyncRequestMsg(syncRequestMsg) + .build()); } @Override public void sendDownlinkResponseMsg(DownlinkResponseMsg downlinkResponseMsg) { - uplinkMsgLock.lock(); + sendRequestMsg(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) + .setDownlinkResponseMsg(downlinkResponseMsg) + .build()); + } + + private void sendRequestMsg(RequestMsg requestMsg) { + connectionLock.lock(); try { - this.inputStream.onNext(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) - .setDownlinkResponseMsg(downlinkResponseMsg) - .build()); + if (inputStream == null) { + throw new IllegalStateException("Edge is not connected to the cloud. The message is discarded!"); + } + inputStream.onNext(requestMsg); } finally { - uplinkMsgLock.unlock(); + connectionLock.unlock(); } } From 33e0cb6619925078d0b1b9f08aa713137bb241e8 Mon Sep 17 00:00:00 2001 From: Nikita Mazurenko Date: Thu, 10 Sep 2026 13:58:57 +0300 Subject: [PATCH 3/7] Revert "Release EdgeGrpcClient channel on failed connect and guard send/disconnect race" This reverts commit b67fc8dfb1ad1ca22dc076047f8ee37743b894f2. --- .../thingsboard/edge/rpc/EdgeGrpcClient.java | 146 +++++++----------- 1 file changed, 54 insertions(+), 92 deletions(-) diff --git a/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java b/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java index f96fe8b38f..7e58a2cb9f 100644 --- a/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java +++ b/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java @@ -86,7 +86,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { private StreamObserver inputStream; - private final ReentrantLock connectionLock = new ReentrantLock(); + private static final ReentrantLock uplinkMsgLock = new ReentrantLock(); @Override public void connect(String edgeKey, @@ -127,38 +127,19 @@ public class EdgeGrpcClient implements EdgeRpcClient { .build()); } - connectionLock.lock(); - try { - channel = builder.build(); - EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel); - log.info("[{}] Sending a connect request to the TB!", edgeKey); - this.inputStream = stub.withCompression("gzip").handleMsgs(initOutputStream(edgeKey, channel, onUplinkResponse, onEdgeUpdate, onDownlink, onError)); - this.inputStream.onNext(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.CONNECT_RPC_MESSAGE) - .setConnectRequestMsg(ConnectRequestMsg.newBuilder() - .setEdgeRoutingKey(edgeKey) - .setEdgeSecret(edgeSecret) - .setEdgeVersion(getNewestEdgeVersion()) - .setMaxInboundMessageSize(maxInboundMessageSize) - .build()) - .build()); - } catch (RuntimeException e) { - // Release the half-built channel, otherwise every failed reconnect attempt leaks - // its event loops and executors, and the next attempt may not recover at all. - log.error("[{}] Failed to establish the connection, shutting down the channel!", edgeKey, e); - if (channel != null) { - try { - channel.shutdownNow(); - } catch (Exception shutdownEx) { - log.error("[{}] Exception during shutdownNow of the failed channel", edgeKey, shutdownEx); - } - } - channel = null; - inputStream = null; - throw e; - } finally { - connectionLock.unlock(); - } + channel = builder.build(); + EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel); + log.info("[{}] Sending a connect request to the TB!", edgeKey); + this.inputStream = stub.withCompression("gzip").handleMsgs(initOutputStream(edgeKey, onUplinkResponse, onEdgeUpdate, onDownlink, onError)); + this.inputStream.onNext(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.CONNECT_RPC_MESSAGE) + .setConnectRequestMsg(ConnectRequestMsg.newBuilder() + .setEdgeRoutingKey(edgeKey) + .setEdgeSecret(edgeSecret) + .setEdgeVersion(getNewestEdgeVersion()) + .setMaxInboundMessageSize(maxInboundMessageSize) + .build()) + .build()); } public static EdgeVersion getNewestEdgeVersion() { @@ -166,7 +147,6 @@ public class EdgeGrpcClient implements EdgeRpcClient { } private StreamObserver initOutputStream(String edgeKey, - ManagedChannel streamChannel, Consumer onUplinkResponse, Consumer onEdgeUpdate, Consumer onDownlink, @@ -186,7 +166,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { } else { log.error("[{}] Failed to establish the connection! Code: {}. Error message: {}.", edgeKey, connectResponseMsg.getResponseCode(), connectResponseMsg.getErrorMsg()); try { - EdgeGrpcClient.this.disconnect(true, streamChannel); + EdgeGrpcClient.this.disconnect(true); } catch (InterruptedException e) { log.error("[{}] Got interruption during disconnect!", edgeKey, e); } @@ -208,7 +188,7 @@ public class EdgeGrpcClient implements EdgeRpcClient { public void onError(Throwable t) { log.warn("[{}] Stream was terminated due to error:", edgeKey, t); try { - EdgeGrpcClient.this.disconnect(true, streamChannel); + EdgeGrpcClient.this.disconnect(true); } catch (InterruptedException e) { log.error("[{}] Got interruption during disconnect!", edgeKey, e); } @@ -224,95 +204,77 @@ public class EdgeGrpcClient implements EdgeRpcClient { @Override public void disconnect(boolean onError) throws InterruptedException { - disconnect(onError, null); - } - - private void disconnect(boolean onError, ManagedChannel expectedChannel) throws InterruptedException { - ManagedChannel channelToShutdown; - connectionLock.lock(); - try { - // A terminated stream reports its error asynchronously and may lose the race with a - // reconnect: ignore such stale callbacks instead of tearing down the fresh channel. - if (expectedChannel != null && channel != expectedChannel) { - log.info("The channel was already replaced by a reconnect. Skipping disconnect of the stale channel."); - return; - } - if (!onError) { - try { - if (inputStream != null) { - inputStream.onCompleted(); - } - } catch (Exception e) { - log.error("Exception during onCompleted", e); + if (!onError) { + try { + if (inputStream != null) { + inputStream.onCompleted(); } + } catch (Exception e) { + log.error("Exception during onCompleted", e); } - // Clear the references under the lock so that no send can start against a stream - // whose channel is shutting down - such a write leaks the compressed ByteBuf. - inputStream = null; - channelToShutdown = channel; - channel = null; - } finally { - connectionLock.unlock(); } - if (channelToShutdown != null) { - channelToShutdown.shutdown(); + if (channel != null) { + channel.shutdown(); int attempt = 0; do { try { - channelToShutdown.awaitTermination(timeoutSecs, TimeUnit.SECONDS); + channel.awaitTermination(timeoutSecs, TimeUnit.SECONDS); } catch (Exception e) { log.error("Channel await termination was interrupted", e); } if (attempt > 5) { log.warn("We had reached maximum of termination attempts. Force closing channel"); try { - channelToShutdown.shutdownNow(); + channel.shutdownNow(); } catch (Exception e) { log.error("Exception during shutdownNow", e); } break; } attempt++; - } while (!channelToShutdown.isTerminated()); + } while (!channel.isTerminated()); } } @Override public void sendUplinkMsg(UplinkMsg msg) { - sendRequestMsg(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) - .setUplinkMsg(msg) - .build()); + uplinkMsgLock.lock(); + try { + this.inputStream.onNext(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) + .setUplinkMsg(msg) + .build()); + } finally { + uplinkMsgLock.unlock(); + } } @Override public void sendSyncRequestMsg(boolean fullSyncRequired) { - SyncRequestMsg syncRequestMsg = SyncRequestMsg.newBuilder() - .setFullSync(fullSyncRequired) - .build(); - sendRequestMsg(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.SYNC_REQUEST_RPC_MESSAGE) - .setSyncRequestMsg(syncRequestMsg) - .build()); + uplinkMsgLock.lock(); + try { + SyncRequestMsg syncRequestMsg = SyncRequestMsg.newBuilder() + .setFullSync(fullSyncRequired) + .build(); + this.inputStream.onNext(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.SYNC_REQUEST_RPC_MESSAGE) + .setSyncRequestMsg(syncRequestMsg) + .build()); + } finally { + uplinkMsgLock.unlock(); + } } @Override public void sendDownlinkResponseMsg(DownlinkResponseMsg downlinkResponseMsg) { - sendRequestMsg(RequestMsg.newBuilder() - .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) - .setDownlinkResponseMsg(downlinkResponseMsg) - .build()); - } - - private void sendRequestMsg(RequestMsg requestMsg) { - connectionLock.lock(); + uplinkMsgLock.lock(); try { - if (inputStream == null) { - throw new IllegalStateException("Edge is not connected to the cloud. The message is discarded!"); - } - inputStream.onNext(requestMsg); + this.inputStream.onNext(RequestMsg.newBuilder() + .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE) + .setDownlinkResponseMsg(downlinkResponseMsg) + .build()); } finally { - connectionLock.unlock(); + uplinkMsgLock.unlock(); } } From 970d590a642ca5d14ab765085f44676f4b18f8b8 Mon Sep 17 00:00:00 2001 From: Nikita Mazurenko Date: Thu, 10 Sep 2026 15:02:46 +0300 Subject: [PATCH 4/7] Serialize JS script release under evalLock and cover both Nashorn backends --- .../script/NashornJsInvokeServiceTest.java | 5 +- .../script/api/js/NashornJsInvokeService.java | 16 ++- .../NashornJsInvokeServiceLifecycleTest.java | 122 ++++++++++++++++++ 3 files changed, 136 insertions(+), 7 deletions(-) create mode 100644 common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java diff --git a/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java b/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java index c76eac8c61..1b0ac652b0 100644 --- a/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/script/NashornJsInvokeServiceTest.java @@ -231,12 +231,13 @@ class NashornJsInvokeServiceTest extends AbstractControllerTest { void whenScriptIsReleased_thenGlobalPropertyIsRemoved() throws Exception { UUID scriptId = evalScript("return msg;"); String functionName = "invokeInternal_" + scriptId.toString().replace('-', '_'); - assertThat(evalInEngine("this.hasOwnProperty('" + functionName + "')")).hasToString("true"); + assertThat(evalInEngine("this.hasOwnProperty('" + functionName + "')")).isEqualTo(true); invokeService.release(scriptId).get(); // the property must be deleted, not just set to undefined: an abandoned binding keeps - assertThat(evalInEngine("this.hasOwnProperty('" + functionName + "')")).hasToString("false"); + // its slot in the Global's PropertyMap forever + assertThat(evalInEngine("this.hasOwnProperty('" + functionName + "')")).isEqualTo(false); } @Test diff --git a/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java b/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java index bb95c60481..32ab55f7ef 100644 --- a/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java +++ b/common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java @@ -144,7 +144,8 @@ public class NashornJsInvokeService extends AbstractJsInvokeService { // that can never be deleted, so every eval/release cycle would grow the Global's PropertyMap // shape history forever. Declaring the function inside an IIFE and assigning it to a global // property keeps the property configurable, allowing doRelease() to actually delete it. - // The prefix stays on the first line so that script line numbers in errors are unchanged. + // The prefix stays on the first line to preserve line numbering on the raw engine path; + // the sandbox beautifier reformats the wrapper and shifts reported error lines anyway. String wrappedScript = "this['" + scriptInfo.getFunctionName() + "'] = (function() { " + jsScript + "\nreturn " + scriptInfo.getFunctionName() + ";\n})();"; return jsExecutor.submit(() -> { @@ -190,10 +191,15 @@ public class NashornJsInvokeService extends AbstractJsInvokeService { protected void doRelease(UUID scriptId, JsScriptInfo scriptInfo) throws ScriptException { String deleteScript = "delete this['" + scriptInfo.getFunctionName() + "'];"; - if (useJsSandbox) { - sandbox.eval(deleteScript); - } else { - engine.eval(deleteScript); + evalLock.lock(); + try { + if (useJsSandbox) { + sandbox.eval(deleteScript); + } else { + engine.eval(deleteScript); + } + } finally { + evalLock.unlock(); } } diff --git a/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java b/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java new file mode 100644 index 0000000000..cdfd2d8e93 --- /dev/null +++ b/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java @@ -0,0 +1,122 @@ +/** + * Copyright © 2016-2026 The Thingsboard Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.thingsboard.script.api.js; + +import delight.nashornsandbox.NashornSandbox; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.Mockito; +import org.springframework.test.util.ReflectionTestUtils; +import org.thingsboard.script.api.ScriptType; +import org.thingsboard.script.api.TbScriptException; +import org.thingsboard.server.common.data.id.TenantId; +import org.thingsboard.server.common.stats.StatsFactory; + +import javax.script.ScriptEngine; +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.ExecutionException; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.mock; + +/** + * Covers the JS global scope lifecycle against both backends the service can be configured with. + * The Spring-wired {@code NashornJsInvokeServiceTest} only exercises the sandbox, since + * {@code js.local.use_js_sandbox} defaults to true. + */ +class NashornJsInvokeServiceLifecycleTest { + + private static final String[] ARG_NAMES = {"msg", "metadata", "msgType"}; + + private NashornJsInvokeService service; + private boolean useJsSandbox; + + @AfterEach + void tearDown() { + if (service != null) { + service.stop(); + } + } + + @ParameterizedTest(name = "useJsSandbox = {0}") + @ValueSource(booleans = {true, false}) + void whenScriptIsReleased_thenGlobalPropertyIsRemovedAndFunctionIsGone(boolean useJsSandbox) throws Exception { + givenService(useJsSandbox); + UUID scriptId = UUID.randomUUID(); + + JsScriptInfo scriptInfo = eval(scriptId, "return {doubled: msg.temperature * 2};"); + assertThat(hasGlobalProperty(scriptInfo)).isTrue(); + assertThat(invoke(scriptId, scriptInfo, "{\"temperature\":21}")).asString().contains("\"doubled\":42"); + + service.doRelease(scriptId); + + assertThat(hasGlobalProperty(scriptInfo)).isFalse(); + assertThatThrownBy(() -> invoke(scriptId, scriptInfo, "{\"temperature\":21}")) + .isInstanceOf(ExecutionException.class) + .cause() + .isInstanceOf(TbScriptException.class); + } + + @ParameterizedTest(name = "useJsSandbox = {0}") + @ValueSource(booleans = {true, false}) + void whenOneOfTwoScriptsIsReleased_thenTheOtherKeepsWorking(boolean useJsSandbox) throws Exception { + givenService(useJsSandbox); + UUID releasedId = UUID.randomUUID(); + UUID retainedId = UUID.randomUUID(); + + JsScriptInfo released = eval(releasedId, "return {v: 1};"); + JsScriptInfo retained = eval(retainedId, "return {v: 2};"); + + service.doRelease(releasedId); + + assertThat(hasGlobalProperty(released)).isFalse(); + assertThat(hasGlobalProperty(retained)).isTrue(); + assertThat(invoke(retainedId, retained, "{}")).asString().contains("\"v\":2"); + } + + private void givenService(boolean useJsSandbox) { + this.useJsSandbox = useJsSandbox; + service = new NashornJsInvokeService(Optional.empty(), Optional.empty()); + ReflectionTestUtils.setField(service, "statsFactory", mock(StatsFactory.class, Mockito.RETURNS_DEEP_STUBS)); + ReflectionTestUtils.setField(service, "useJsSandbox", useJsSandbox); + ReflectionTestUtils.setField(service, "jsExecutorThreadPoolSize", 4); + ReflectionTestUtils.setField(service, "monitorThreadPoolSize", 2); + ReflectionTestUtils.setField(service, "maxCpuTime", 8000L); + ReflectionTestUtils.setField(service, "maxMemory", 104857600L); + service.init(); + } + + private JsScriptInfo eval(UUID scriptId, String scriptBody) throws Exception { + service.doEvalScript(TenantId.SYS_TENANT_ID, ScriptType.RULE_NODE_SCRIPT, scriptBody, scriptId, ARG_NAMES).get(); + return service.scriptInfoMap.get(scriptId); + } + + private Object invoke(UUID scriptId, JsScriptInfo scriptInfo, String msg) throws Exception { + return service.doInvokeFunction(scriptId, scriptInfo, new Object[]{msg, "{}", "POST_TELEMETRY_REQUEST"}).get(); + } + + private boolean hasGlobalProperty(JsScriptInfo scriptInfo) throws Exception { + String expression = "this.hasOwnProperty('" + scriptInfo.getFunctionName() + "')"; + Object result = useJsSandbox + ? ((NashornSandbox) ReflectionTestUtils.getField(service, "sandbox")).eval(expression) + : ((ScriptEngine) ReflectionTestUtils.getField(service, "engine")).eval(expression); + return Boolean.TRUE.equals(result); + } + +} From 191d7798143120f11e0c44e375d0c9d8099d7028 Mon Sep 17 00:00:00 2001 From: Dmytro Pinkevych <49400214+pinkevmladchy@users.noreply.github.com> Date: Mon, 21 Sep 2026 18:39:14 +0300 Subject: [PATCH 5/7] Keep IoT Hub markdown table columns from overlapping (#16138) * Keep IoT Hub markdown table columns from overlapping Long unbreakable values in solution instruction tables (logins, e-mails, passwords) overflowed their own column and ran under the copy icon. Cells now break such tokens with overflow-wrap: anywhere, cells holding a copy button reserve room for the icon, and the table is sized by its content instead of splitting the width equally between all columns. * Let preformatted content in markdown table cells wrap With auto layout a cell holding a preformatted block keeps the whole line as its min-content width, which the table cannot shrink below: in a 396px host the table measured 701px and a host that hides horizontal overflow, such as the item detail dialog's .dlg-body, cut the overflow off with no way to scroll to it. Relaxing the block and the code inside it to pre-wrap lets the cell shrink with the table. * Derive the copy icon space in table cells from the icon geometry The 44px reserved on the right of a copy-code cell was derived by hand from the copy icon chip declared 45 lines above it, so nudging the chip's width or offset would silently put the cell text back under the icon. Both numbers now live in $copy-icon-width and $copy-icon-offset, used by the chip itself and by the reservation, which is written as width plus the gap on either side. --- .../iot-hub/iot-hub-markdown.component.scss | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss index 2a946348ad..c25c67e729 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss @@ -3,6 +3,10 @@ $text-color: rgba(0,0,0,0.76); $link-color: #2a7dec; $copy-button-color: #2a7dec; +// Geometry of the copy icon chip, shared by the chip itself and by the space table +// cells reserve for it, so the two cannot drift apart. +$copy-icon-width: 38px; +$copy-icon-offset: 3px; $code-block-border-color: rgba(42, 125, 236, .2); $code-default-color: #212529; @@ -169,10 +173,10 @@ $gallery-border-hover-color: #2a7dec; div { background-color: #fff; position: absolute; - width: 38px; + width: $copy-icon-width; height: 28px; - top: 3px; - right: 3px; + top: $copy-icon-offset; + right: $copy-icon-offset; padding: 8px 10px 0; img { @@ -204,9 +208,30 @@ $gallery-border-hover-color: #2a7dec; } th, td { + // Long unbreakable tokens (logins, e-mails, passwords) must never overflow their + // own column. `anywhere` also drops the cell min-content width down to a single + // character, so auto layout can always squeeze the table into the available + // width instead of overflowing (and getting clipped by `overflow: hidden`). + overflow-wrap: break-word; // fallback for engines without `anywhere` + overflow-wrap: anywhere; + + // Text is not the only thing that can outgrow a column: a preformatted block keeps + // its whole line as min-content width, which auto layout cannot shrink, so the table + // would push past its container and get cut off by a host that hides horizontal + // overflow (iot-hub-item-detail-dialog's .dlg-body). Wrap it inside the cell instead. + // Prism sets `white-space: pre` on both the block and the code inside it, so both + // have to be relaxed for the cell to shrink. + pre, pre > code { + white-space: pre-wrap; + } + div.code-wrapper { display: inline-block; width: 100%; + // Reserve room for the absolutely positioned copy icon, plus the same gap on its + // far side, so the cell text does not run underneath it and the reservation + // follows the chip if its geometry ever changes. + padding-right: $copy-icon-width + 2 * $copy-icon-offset; button.clipboard-btn { top: -6px; @@ -275,11 +300,10 @@ $gallery-border-hover-color: #2a7dec; margin-top: 20px; margin-bottom: 20px; overflow: hidden; - table-layout: fixed; - - &.auto { - table-layout: auto; - } + // Columns are sized to their content: with fixed layout every column got the + // same width, so cells with long values (e-mails, logins, tokens) had to wrap + // mid-word while short columns kept a lot of unused space. + table-layout: auto; > thead { background-color: $table-header-background-color; From 89e2e086fb05980208b62d630e0737bce58c1263 Mon Sep 17 00:00:00 2001 From: Dmytro Pinkevych <49400214+pinkevmladchy@users.noreply.github.com> Date: Mon, 21 Sep 2026 18:39:29 +0300 Subject: [PATCH 6/7] Refresh the installed items count after an install, update or delete (#16139) * Refresh the installed items count after an install, update or delete The IoT Hub items page loaded its installed-items counter once, so installing, updating or deleting an item from the embedded browse list left the counter showing a stale number until the page was reloaded. The browse component now emits installedItemsChanged whenever it refreshes its own installed-items state, and the page reloads the counter on that event. * Refresh the installed items count from the device wizard and deep links too The device install wizard registers the install as soon as the entity steps finish, but closing it with the header X or with Cancel on a still-pending later step resolved to false, so the caller never reloaded. It now reports 'installed' once the server has the installed item, whichever way it is closed. The deep-linked item dialog is opened by the items page itself, so its outcome was discarded. It now refreshes the browse grid, which in turn announces the new count. --- .../device-install-dialog.component.ts | 9 ++++++++- .../iot-hub/iot-hub-browse.component.ts | 12 +++++++++++- .../iot-hub/iot-hub-items-page.component.html | 3 ++- .../pages/iot-hub/iot-hub-items-page.component.ts | 15 ++++++++++++--- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts index 676ad706b1..7f991316ee 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts @@ -95,6 +95,12 @@ export class TbDeviceInstallDialogComponent extends DialogComponent = {}; @@ -357,7 +363,7 @@ export class TbDeviceInstallDialogComponent extends DialogComponent(); + /** + * Fired whenever an install, update or delete changed what this tenant has installed, so a host + * page showing its own installed-items counter can refresh it instead of waiting for a reload. + */ + @Output() installedItemsChanged = new EventEmitter(); @Input() set activeType(value: ItemType) { if (value && value !== this._activeType) { const wasInit = !!this._activeType; @@ -627,7 +632,11 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy }); } - private reloadInstalledItems(): void { + /** + * Re-reads what is installed for the active type and announces the change. Public so a host page + * that opens the item detail dialog itself can refresh this grid through the same path. + */ + reloadInstalledItems(): void { const config = {ignoreLoading: true}; const pageLink = new PageLink(10000, 0); if (this.activeType === ItemType.WIDGET) { @@ -643,6 +652,7 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy this.installedItemCounts = counts; }); } + this.installedItemsChanged.emit(); } private loadFilterInfo(): void { diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html index 59a42eab29..5787b5ecf0 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html @@ -35,7 +35,8 @@ + [hideTabs]="true" + (installedItemsChanged)="loadInstalledCount()"> diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts index b89448be3c..07beff5559 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts @@ -1,12 +1,13 @@ // SPDX-FileCopyrightText: Copyright The Thingsboard Authors // SPDX-License-Identifier: Apache-2.0 -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { map } from 'rxjs/operators'; import { Observable } from 'rxjs'; import { ItemType } from '@shared/models/iot-hub/iot-hub-item.models'; import { IotHubApiService } from '@core/http/iot-hub-api.service'; import { IotHubActionsService } from '@home/components/iot-hub/iot-hub-actions.service'; +import { TbIotHubBrowseComponent } from '@home/components/iot-hub/iot-hub-browse.component'; import { IotHubInstalledItem } from '@shared/models/iot-hub/iot-hub-installed-item.models'; import { MpItemVersionView } from '@shared/models/iot-hub/iot-hub-version.models'; import { PageLink } from '@shared/models/page/page-link'; @@ -83,6 +84,8 @@ export class TbIotHubItemsPageComponent implements OnInit { config: ItemTypePageConfig; installedItemsCount = 0; + @ViewChild(TbIotHubBrowseComponent) private browse: TbIotHubBrowseComponent; + constructor( private route: ActivatedRoute, private router: Router, @@ -109,7 +112,7 @@ export class TbIotHubItemsPageComponent implements OnInit { window.open(this.iotHubApiService.baseUrl + '/signup', '_blank'); } - private loadInstalledCount(): void { + loadInstalledCount(): void { this.iotHubApiService.getInstalledItemsCount(this.config.type, { ignoreLoading: true }).subscribe(count => { this.installedItemsCount = count; }); @@ -147,7 +150,13 @@ export class TbIotHubItemsPageComponent implements OnInit { 'default', true, openItem.preview - ).subscribe(); + ).subscribe(result => { + // The deep-linked dialog is opened by this page rather than by the grid, so its outcome + // has to be fed back in by hand — the grid then refreshes and announces the new count. + if (result === 'installed' || result === 'updated' || result === 'deleted') { + this.browse?.reloadInstalledItems(); + } + }); }); } From b02a7d0817c053f779b54f8e952a62d72e4d8772 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Tue, 22 Sep 2026 16:43:19 +0300 Subject: [PATCH 7/7] Fix license headers --- .../service/edge/rpc/EdgeGrpcServiceTest.java | 17 ++--------------- .../js/NashornJsInvokeServiceLifecycleTest.java | 17 ++--------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java b/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java index 7b71c65c9f..80730f9f53 100644 --- a/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java @@ -1,18 +1,5 @@ -/** - * Copyright © 2016-2026 The Thingsboard Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-FileCopyrightText: Copyright The Thingsboard Authors +// SPDX-License-Identifier: Apache-2.0 package org.thingsboard.server.service.edge.rpc; import org.junit.jupiter.api.BeforeEach; diff --git a/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java b/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java index cdfd2d8e93..673e06d5a8 100644 --- a/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java +++ b/common/script/script-api/src/test/java/org/thingsboard/script/api/js/NashornJsInvokeServiceLifecycleTest.java @@ -1,18 +1,5 @@ -/** - * Copyright © 2016-2026 The Thingsboard Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-FileCopyrightText: Copyright The Thingsboard Authors +// SPDX-License-Identifier: Apache-2.0 package org.thingsboard.script.api.js; import delight.nashornsandbox.NashornSandbox;