diff --git a/application/pom.xml b/application/pom.xml
index 9a46bbdc3a..9c6d05d31f 100644
--- a/application/pom.xml
+++ b/application/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
thingsboard
application
diff --git a/application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcSession.java b/application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcSession.java
index 1e9a0ade87..aeab041c7f 100644
--- a/application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcSession.java
+++ b/application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcSession.java
@@ -269,7 +269,12 @@ public abstract class EdgeGrpcSession implements Closeable {
@Override
public void onFailure(Throwable t) {
- log.error("[{}][{}] Exception during sync process", tenantId, edge.getId(), t);
+ log.error("[{}][{}] Exception during sync process, skipping fetcher {} and continuing",
+ tenantId, edge.getId(), next.getClass().getSimpleName(), t);
+ // Keep walking the cursor: returning here leaves syncInProgress set for the life of the
+ // session, so the edge never receives SyncCompletedMsg and both general downlink delivery
+ // and uplink processing stay gated until the session is re-established.
+ doSync(cursor);
}
}, ctx.getGrpcCallbackExecutorService());
} else {
diff --git a/application/src/main/java/org/thingsboard/server/service/telemetry/AbstractSubscriptionService.java b/application/src/main/java/org/thingsboard/server/service/telemetry/AbstractSubscriptionService.java
index 5df3e638f5..7b5a2a0fad 100644
--- a/application/src/main/java/org/thingsboard/server/service/telemetry/AbstractSubscriptionService.java
+++ b/application/src/main/java/org/thingsboard/server/service/telemetry/AbstractSubscriptionService.java
@@ -25,6 +25,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.common.util.ThingsBoardThreadFactory;
import org.thingsboard.server.cluster.TbClusterService;
+import org.thingsboard.server.common.data.exception.TenantNotFoundException;
import org.thingsboard.server.common.data.id.EntityId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.msg.queue.ServiceType;
@@ -86,7 +87,15 @@ public abstract class AbstractSubscriptionService extends TbApplicationEventList
protected void forwardToSubscriptionManagerService(TenantId tenantId, EntityId entityId,
Consumer toSubscriptionManagerService,
Supplier toCore) {
- TopicPartitionInfo tpi = partitionService.resolve(ServiceType.TB_CORE, tenantId, entityId);
+ TopicPartitionInfo tpi;
+ try {
+ tpi = partitionService.resolve(ServiceType.TB_CORE, tenantId, entityId);
+ } catch (TenantNotFoundException e) {
+ // The tenant was deleted (e.g. concurrently with an in-flight asynchronous save callback),
+ // so there is no partition to route to and no subscribers to notify. Nothing to forward.
+ log.debug("[{}][{}] Skipping subscription update: tenant no longer exists.", tenantId, entityId);
+ return;
+ }
if (currentPartitions.contains(tpi)) {
if (subscriptionManagerService.isPresent()) {
toSubscriptionManagerService.accept(subscriptionManagerService.get());
diff --git a/application/src/test/java/org/thingsboard/server/service/telemetry/DefaultTelemetrySubscriptionServiceTest.java b/application/src/test/java/org/thingsboard/server/service/telemetry/DefaultTelemetrySubscriptionServiceTest.java
index dcfe9bd2bd..958a41449f 100644
--- a/application/src/test/java/org/thingsboard/server/service/telemetry/DefaultTelemetrySubscriptionServiceTest.java
+++ b/application/src/test/java/org/thingsboard/server/service/telemetry/DefaultTelemetrySubscriptionServiceTest.java
@@ -40,6 +40,7 @@ import org.thingsboard.server.common.data.ApiUsageStateValue;
import org.thingsboard.server.common.data.AttributeScope;
import org.thingsboard.server.common.data.EntityType;
import org.thingsboard.server.common.data.EntityView;
+import org.thingsboard.server.common.data.exception.TenantNotFoundException;
import org.thingsboard.server.common.data.id.ApiUsageStateId;
import org.thingsboard.server.common.data.id.CustomerId;
import org.thingsboard.server.common.data.id.DeviceId;
@@ -89,6 +90,7 @@ import java.util.stream.Stream;
import static com.google.common.util.concurrent.Futures.immediateFailedFuture;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
@@ -1155,6 +1157,26 @@ class DefaultTelemetrySubscriptionServiceTest {
then(deviceStateManager).shouldHaveNoInteractions();
}
+ /* --- Subscription forwarding --- */
+
+ @Test
+ void shouldSkipSubscriptionForwardWhenTenantWasDeleted() {
+ // GIVEN the tenant was deleted concurrently, so partition resolution fails
+ given(partitionService.resolve(ServiceType.TB_CORE, tenantId, entityId))
+ .willThrow(new TenantNotFoundException(tenantId));
+
+ // WHEN forwarding a subscription update (e.g. from an in-flight async save callback)
+ // THEN it must not propagate the exception
+ assertThatNoException().isThrownBy(() -> telemetryService.forwardToSubscriptionManagerService(
+ tenantId, entityId,
+ sm -> sm.onAttributesUpdate(tenantId, entityId, AttributeScope.SERVER_SCOPE.name(), List.of(), TbCallback.EMPTY),
+ () -> null));
+
+ // AND nothing is forwarded, since there is no partition to route to and no subscribers to notify
+ then(subscriptionManagerService).shouldHaveNoInteractions();
+ then(clusterService).shouldHaveNoInteractions();
+ }
+
// used to emulate versions returned by save APIs
private static List listOfNNumbers(int N) {
return LongStream.range(0, N).boxed().toList();
diff --git a/common/actor/pom.xml b/common/actor/pom.xml
index 7d6aba753b..05dbdae924 100644
--- a/common/actor/pom.xml
+++ b/common/actor/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/cache/pom.xml b/common/cache/pom.xml
index 4db50b2380..3413e7c22f 100644
--- a/common/cache/pom.xml
+++ b/common/cache/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/cluster-api/pom.xml b/common/cluster-api/pom.xml
index 48d931bb53..29736b874e 100644
--- a/common/cluster-api/pom.xml
+++ b/common/cluster-api/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/coap-server/pom.xml b/common/coap-server/pom.xml
index d6d1d1d69b..f889c6bcaa 100644
--- a/common/coap-server/pom.xml
+++ b/common/coap-server/pom.xml
@@ -22,7 +22,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/dao-api/pom.xml b/common/dao-api/pom.xml
index a0f9a8be78..987d753d2c 100644
--- a/common/dao-api/pom.xml
+++ b/common/dao-api/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/data/pom.xml b/common/data/pom.xml
index a2b9dce687..527bc39881 100644
--- a/common/data/pom.xml
+++ b/common/data/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/discovery-api/pom.xml b/common/discovery-api/pom.xml
index 38774d93f7..df8f86335f 100644
--- a/common/discovery-api/pom.xml
+++ b/common/discovery-api/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/edge-api/pom.xml b/common/edge-api/pom.xml
index 9141a164d8..2cbf7a2672 100644
--- a/common/edge-api/pom.xml
+++ b/common/edge-api/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
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..2237e06f43 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
@@ -19,8 +19,17 @@ import io.grpc.HttpConnectProxiedSocketAddress;
import io.grpc.ManagedChannel;
import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts;
import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;
+import io.grpc.netty.shaded.io.netty.channel.Channel;
+import io.grpc.netty.shaded.io.netty.channel.EventLoopGroup;
+import io.grpc.netty.shaded.io.netty.channel.epoll.Epoll;
+import io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup;
+import io.grpc.netty.shaded.io.netty.channel.epoll.EpollSocketChannel;
+import io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoopGroup;
+import io.grpc.netty.shaded.io.netty.channel.socket.nio.NioSocketChannel;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContextBuilder;
+import io.grpc.netty.shaded.io.netty.util.concurrent.DefaultThreadFactory;
import io.grpc.stub.StreamObserver;
+import jakarta.annotation.PreDestroy;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@@ -84,8 +93,14 @@ public class EdgeGrpcClient implements EdgeRpcClient {
private ManagedChannel channel;
+ private final EventLoopGroup workerGroup = createWorkerGroup();
+
private StreamObserver inputStream;
+ private volatile boolean connected;
+
+ private volatile boolean streamActive;
+
private static final ReentrantLock uplinkMsgLock = new ReentrantLock();
@Override
@@ -95,7 +110,11 @@ public class EdgeGrpcClient implements EdgeRpcClient {
Consumer onEdgeUpdate,
Consumer onDownlink,
Consumer onError) {
+ connected = false;
+ streamActive = false;
NettyChannelBuilder builder = NettyChannelBuilder.forAddress(rpcHost, rpcPort)
+ .eventLoopGroup(workerGroup)
+ .channelType(channelType())
.maxInboundMessageSize(maxInboundMessageSize)
.keepAliveTime(keepAliveTimeSec, TimeUnit.SECONDS)
.keepAliveTimeout(keepAliveTimeoutSec, TimeUnit.SECONDS)
@@ -131,6 +150,7 @@ public class EdgeGrpcClient implements EdgeRpcClient {
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));
+ streamActive = true;
this.inputStream.onNext(RequestMsg.newBuilder()
.setMsgType(RequestMsgType.CONNECT_RPC_MESSAGE)
.setConnectRequestMsg(ConnectRequestMsg.newBuilder()
@@ -146,6 +166,20 @@ public class EdgeGrpcClient implements EdgeRpcClient {
return EdgeVersionComparator.getNewestEdgeVersion();
}
+ private static EventLoopGroup createWorkerGroup() {
+ DefaultThreadFactory threadFactory = new DefaultThreadFactory("edge-grpc-worker", true);
+ return Epoll.isAvailable() ? new EpollEventLoopGroup(1, threadFactory) : new NioEventLoopGroup(1, threadFactory);
+ }
+
+ private static Class extends Channel> channelType() {
+ return Epoll.isAvailable() ? EpollSocketChannel.class : NioSocketChannel.class;
+ }
+
+ @PreDestroy
+ public void destroy() {
+ workerGroup.shutdownGracefully();
+ }
+
private StreamObserver initOutputStream(String edgeKey,
Consumer onUplinkResponse,
Consumer onEdgeUpdate,
@@ -162,8 +196,10 @@ public class EdgeGrpcClient implements EdgeRpcClient {
serverMaxInboundMessageSize = connectResponseMsg.getMaxInboundMessageSize();
}
log.info("[{}] Configuration received: {}", edgeKey, connectResponseMsg.getConfiguration());
+ connected = true;
onEdgeUpdate.accept(connectResponseMsg.getConfiguration());
} else {
+ connected = false;
log.error("[{}] Failed to establish the connection! Code: {}. Error message: {}.", edgeKey, connectResponseMsg.getResponseCode(), connectResponseMsg.getErrorMsg());
try {
EdgeGrpcClient.this.disconnect(true);
@@ -186,6 +222,8 @@ public class EdgeGrpcClient implements EdgeRpcClient {
@Override
public void onError(Throwable t) {
+ connected = false;
+ streamActive = false;
log.warn("[{}] Stream was terminated due to error:", edgeKey, t);
try {
EdgeGrpcClient.this.disconnect(true);
@@ -197,6 +235,8 @@ public class EdgeGrpcClient implements EdgeRpcClient {
@Override
public void onCompleted() {
+ connected = false;
+ streamActive = false;
log.info("[{}] Stream was closed and completed successfully!", edgeKey);
}
};
@@ -204,6 +244,8 @@ public class EdgeGrpcClient implements EdgeRpcClient {
@Override
public void disconnect(boolean onError) throws InterruptedException {
+ connected = false;
+ streamActive = false;
if (!onError) {
try {
if (inputStream != null) {
@@ -236,10 +278,19 @@ public class EdgeGrpcClient implements EdgeRpcClient {
}
}
+ @Override
+ public boolean isConnected() {
+ return connected;
+ }
+
@Override
public void sendUplinkMsg(UplinkMsg msg) {
uplinkMsgLock.lock();
try {
+ if (!streamActive) {
+ log.debug("Uplink msg is skipped, the cloud session is not established: {}", msg);
+ return;
+ }
this.inputStream.onNext(RequestMsg.newBuilder()
.setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE)
.setUplinkMsg(msg)
@@ -253,6 +304,10 @@ public class EdgeGrpcClient implements EdgeRpcClient {
public void sendSyncRequestMsg(boolean fullSyncRequired) {
uplinkMsgLock.lock();
try {
+ if (!streamActive) {
+ log.debug("Sync request msg is skipped, the cloud session is not established");
+ return;
+ }
SyncRequestMsg syncRequestMsg = SyncRequestMsg.newBuilder()
.setFullSync(fullSyncRequired)
.build();
@@ -269,6 +324,10 @@ public class EdgeGrpcClient implements EdgeRpcClient {
public void sendDownlinkResponseMsg(DownlinkResponseMsg downlinkResponseMsg) {
uplinkMsgLock.lock();
try {
+ if (!streamActive) {
+ log.debug("Downlink response msg is skipped, the cloud session is not established: {}", downlinkResponseMsg);
+ return;
+ }
this.inputStream.onNext(RequestMsg.newBuilder()
.setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE)
.setDownlinkResponseMsg(downlinkResponseMsg)
diff --git a/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeRpcClient.java b/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeRpcClient.java
index 267fd2b3f2..d9a05ab2ce 100644
--- a/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeRpcClient.java
+++ b/common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeRpcClient.java
@@ -34,6 +34,8 @@ public interface EdgeRpcClient {
void disconnect(boolean onError) throws InterruptedException;
+ boolean isConnected();
+
void sendSyncRequestMsg(boolean fullSyncRequired);
void sendUplinkMsg(UplinkMsg uplinkMsg);
diff --git a/common/edge-api/src/main/proto/edge.proto b/common/edge-api/src/main/proto/edge.proto
index 376a4d8c5b..8650087f74 100644
--- a/common/edge-api/src/main/proto/edge.proto
+++ b/common/edge-api/src/main/proto/edge.proto
@@ -50,6 +50,7 @@ enum EdgeVersion {
V_4_2_2_2 = 4222;
V_4_2_2_3 = 4223;
V_4_2_2_4 = 4224;
+ V_4_2_2_5 = 4225;
V_LATEST = 99999;
}
diff --git a/common/edge-api/src/test/java/org/thingsboard/edge/rpc/EdgeGrpcClientLeakTest.java b/common/edge-api/src/test/java/org/thingsboard/edge/rpc/EdgeGrpcClientLeakTest.java
new file mode 100644
index 0000000000..9fc66ed33e
--- /dev/null
+++ b/common/edge-api/src/test/java/org/thingsboard/edge/rpc/EdgeGrpcClientLeakTest.java
@@ -0,0 +1,168 @@
+/**
+ * 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.edge.rpc;
+
+import io.grpc.Server;
+import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder;
+import io.grpc.netty.shaded.io.netty.buffer.PooledByteBufAllocator;
+import io.grpc.stub.StreamObserver;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.test.util.ReflectionTestUtils;
+import org.thingsboard.server.gen.edge.v1.ConnectResponseCode;
+import org.thingsboard.server.gen.edge.v1.ConnectResponseMsg;
+import org.thingsboard.server.gen.edge.v1.EdgeRpcServiceGrpc;
+import org.thingsboard.server.gen.edge.v1.RequestMsg;
+import org.thingsboard.server.gen.edge.v1.RequestMsgType;
+import org.thingsboard.server.gen.edge.v1.ResponseMsg;
+import org.thingsboard.server.gen.edge.v1.UplinkMsg;
+
+import java.lang.reflect.Method;
+import java.util.concurrent.TimeUnit;
+import java.util.function.BooleanSupplier;
+
+import static org.junit.jupiter.api.Assertions.fail;
+
+class EdgeGrpcClientLeakTest {
+
+ // The window in which the default shared event loop group would be destroyed after the channel
+ // terminates (SharedResourceHolder delays destruction by 1 second). If EdgeGrpcClient ever goes
+ // back to the shared group, writes after this window hit a terminated executor and every buffer
+ // committed to grpc-netty's WriteQueue is pinned forever (4112 bytes per message, silent after
+ // the first RejectedExecutionException).
+ private static final long SHARED_GROUP_DEATH_WINDOW_MS = 3000;
+ private static final int MSG_COUNT = 50;
+ private static final long AWAIT_TIMEOUT_MS = 15_000;
+
+ private Server server;
+ private EdgeGrpcClient client;
+
+ @Test
+ void uplinksSentAfterTransportDeathDoNotPinPooledBuffers() throws Exception {
+ server = NettyServerBuilder.forPort(0)
+ .addService(new EdgeRpcServiceGrpc.EdgeRpcServiceImplBase() {
+ @Override
+ public StreamObserver handleMsgs(StreamObserver outputStream) {
+ return new StreamObserver<>() {
+ @Override
+ public void onNext(RequestMsg requestMsg) {
+ if (requestMsg.hasConnectRequestMsg()) {
+ outputStream.onNext(ResponseMsg.newBuilder()
+ .setConnectResponseMsg(ConnectResponseMsg.newBuilder()
+ .setResponseCode(ConnectResponseCode.ACCEPTED)
+ .build())
+ .build());
+ }
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ }
+
+ @Override
+ public void onCompleted() {
+ }
+ };
+ }
+ })
+ .build()
+ .start();
+
+ client = new EdgeGrpcClient();
+ ReflectionTestUtils.setField(client, "rpcHost", "localhost");
+ ReflectionTestUtils.setField(client, "rpcPort", server.getPort());
+ ReflectionTestUtils.setField(client, "timeoutSecs", 1);
+ ReflectionTestUtils.setField(client, "keepAliveTimeSec", 10);
+ ReflectionTestUtils.setField(client, "keepAliveTimeoutSec", 5);
+ ReflectionTestUtils.setField(client, "maxInboundMessageSize", 4194304);
+
+ client.connect("leakTest", "leakTest", msg -> {}, cfg -> {}, msg -> {}, e -> {});
+ await("client to connect", () -> client.isConnected());
+
+ server.shutdownNow();
+ server.awaitTermination(10, TimeUnit.SECONDS);
+ await("client to observe the transport death", () -> !client.isConnected());
+ Thread.sleep(SHARED_GROUP_DEATH_WINDOW_MS);
+
+ long baseline = pinnedBytes();
+ @SuppressWarnings("unchecked")
+ StreamObserver inputStream = (StreamObserver) ReflectionTestUtils.getField(client, "inputStream");
+ RequestMsg uplink = RequestMsg.newBuilder()
+ .setMsgType(RequestMsgType.UPLINK_RPC_MESSAGE)
+ .setUplinkMsg(UplinkMsg.newBuilder().setUplinkMsgId(1).build())
+ .build();
+ // Bypasses the connected gate on purpose: this models the check-then-act straggler (and the
+ // pre-gate retry loop) writing to a stream whose transport is already gone. Exceptions are
+ // swallowed the same way the production retry loop survives them.
+ for (int i = 0; i < MSG_COUNT; i++) {
+ try {
+ inputStream.onNext(uplink);
+ } catch (RuntimeException ignored) {
+ }
+ }
+
+ long deadline = System.currentTimeMillis() + AWAIT_TIMEOUT_MS;
+ while (pinnedBytes() > baseline) {
+ if (System.currentTimeMillis() > deadline) {
+ fail("Pinned pooled memory did not return to baseline: " + (pinnedBytes() - baseline)
+ + " bytes retained after " + MSG_COUNT + " uplinks to a dead stream");
+ }
+ Thread.sleep(50);
+ }
+ }
+
+ @AfterEach
+ void tearDown() throws Exception {
+ if (client != null) {
+ client.disconnect(true);
+ client.destroy();
+ }
+ if (server != null) {
+ server.shutdownNow();
+ }
+ }
+
+ private void await(String what, BooleanSupplier condition) throws InterruptedException {
+ long deadline = System.currentTimeMillis() + AWAIT_TIMEOUT_MS;
+ while (!condition.getAsBoolean()) {
+ if (System.currentTimeMillis() > deadline) {
+ fail("Timed out waiting for " + what);
+ }
+ Thread.sleep(50);
+ }
+ }
+
+ // grpc-netty builds its own PooledByteBufAllocator instances instead of using
+ // PooledByteBufAllocator.DEFAULT, and the factory that owns them is package private - so they
+ // have to be pulled out reflectively. Both variants are checked so the assertion holds no matter
+ // which one the transport picks on this platform/version.
+ private static long pinnedBytes() {
+ try {
+ Class> utils = Class.forName("io.grpc.netty.shaded.io.grpc.netty.Utils");
+ Method getByteBufAllocator = utils.getDeclaredMethod("getByteBufAllocator", boolean.class);
+ getByteBufAllocator.setAccessible(true);
+ long total = 0;
+ for (boolean forceHeapBuffer : new boolean[]{false, true}) {
+ PooledByteBufAllocator pooled = (PooledByteBufAllocator) getByteBufAllocator.invoke(null, forceHeapBuffer);
+ total += pooled.pinnedDirectMemory() + pooled.pinnedHeapMemory();
+ }
+ return total;
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to read the gRPC allocator metrics", e);
+ }
+ }
+
+}
diff --git a/common/edqs/pom.xml b/common/edqs/pom.xml
index ae62259f79..f17be58106 100644
--- a/common/edqs/pom.xml
+++ b/common/edqs/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/message/pom.xml b/common/message/pom.xml
index d338f57946..d92d489c84 100644
--- a/common/message/pom.xml
+++ b/common/message/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/pom.xml b/common/pom.xml
index 1eb2dc44b2..665367ddc3 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
thingsboard
common
diff --git a/common/proto/pom.xml b/common/proto/pom.xml
index c2f898bb38..eb10742275 100644
--- a/common/proto/pom.xml
+++ b/common/proto/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/queue/pom.xml b/common/queue/pom.xml
index e714fc749b..13a5ac837c 100644
--- a/common/queue/pom.xml
+++ b/common/queue/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/script/pom.xml b/common/script/pom.xml
index 46a97d2ece..b2f1011c79 100644
--- a/common/script/pom.xml
+++ b/common/script/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/script/remote-js-client/pom.xml b/common/script/remote-js-client/pom.xml
index 0f9191e3cc..7f285986ca 100644
--- a/common/script/remote-js-client/pom.xml
+++ b/common/script/remote-js-client/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard.common
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
script
org.thingsboard.common.script
diff --git a/common/script/script-api/pom.xml b/common/script/script-api/pom.xml
index 6752190015..826392ce6a 100644
--- a/common/script/script-api/pom.xml
+++ b/common/script/script-api/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard.common
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
script
org.thingsboard.common.script
diff --git a/common/stats/pom.xml b/common/stats/pom.xml
index ae013f938c..e9340252e5 100644
--- a/common/stats/pom.xml
+++ b/common/stats/pom.xml
@@ -22,7 +22,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/transport/coap/pom.xml b/common/transport/coap/pom.xml
index 79c1e4c06b..35a7b96c41 100644
--- a/common/transport/coap/pom.xml
+++ b/common/transport/coap/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard.common
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
org.thingsboard.common.transport
diff --git a/common/transport/http/pom.xml b/common/transport/http/pom.xml
index 801fb49117..5cbccd7ede 100644
--- a/common/transport/http/pom.xml
+++ b/common/transport/http/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard.common
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
org.thingsboard.common.transport
diff --git a/common/transport/lwm2m/pom.xml b/common/transport/lwm2m/pom.xml
index a4892f9f80..9a7e8ddad5 100644
--- a/common/transport/lwm2m/pom.xml
+++ b/common/transport/lwm2m/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard.common
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
org.thingsboard.common.transport
diff --git a/common/transport/mqtt/pom.xml b/common/transport/mqtt/pom.xml
index a6c0686b4b..6664d14d1d 100644
--- a/common/transport/mqtt/pom.xml
+++ b/common/transport/mqtt/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard.common
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
org.thingsboard.common.transport
diff --git a/common/transport/pom.xml b/common/transport/pom.xml
index dc12d0d7b5..ec420af200 100644
--- a/common/transport/pom.xml
+++ b/common/transport/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/transport/snmp/pom.xml b/common/transport/snmp/pom.xml
index b1b2ed7343..ccabdf75af 100644
--- a/common/transport/snmp/pom.xml
+++ b/common/transport/snmp/pom.xml
@@ -21,7 +21,7 @@
org.thingsboard.common
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
diff --git a/common/transport/transport-api/pom.xml b/common/transport/transport-api/pom.xml
index a11c5b17d1..723b95a74f 100644
--- a/common/transport/transport-api/pom.xml
+++ b/common/transport/transport-api/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard.common
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
org.thingsboard.common.transport
diff --git a/common/util/pom.xml b/common/util/pom.xml
index db60495e95..c6584ec7b2 100644
--- a/common/util/pom.xml
+++ b/common/util/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/common/version-control/pom.xml b/common/version-control/pom.xml
index 28a7e6e332..4c67a2c476 100644
--- a/common/version-control/pom.xml
+++ b/common/version-control/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
common
org.thingsboard.common
diff --git a/dao/pom.xml b/dao/pom.xml
index 19c089dee1..83bc3ccf85 100644
--- a/dao/pom.xml
+++ b/dao/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
thingsboard
dao
diff --git a/edqs/pom.xml b/edqs/pom.xml
index bdae55999d..92f2541039 100644
--- a/edqs/pom.xml
+++ b/edqs/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
thingsboard
edqs
diff --git a/monitoring/pom.xml b/monitoring/pom.xml
index 2026a40f70..efd6dab9a3 100644
--- a/monitoring/pom.xml
+++ b/monitoring/pom.xml
@@ -21,7 +21,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
thingsboard
diff --git a/msa/black-box-tests/pom.xml b/msa/black-box-tests/pom.xml
index a78bea8969..bab206418b 100644
--- a/msa/black-box-tests/pom.xml
+++ b/msa/black-box-tests/pom.xml
@@ -21,7 +21,7 @@
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
msa
org.thingsboard.msa
diff --git a/msa/edqs/pom.xml b/msa/edqs/pom.xml
index 74a6e58ad9..247e1116b1 100644
--- a/msa/edqs/pom.xml
+++ b/msa/edqs/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
msa
org.thingsboard.msa
diff --git a/msa/js-executor/package.json b/msa/js-executor/package.json
index de6339b518..e88f5da2eb 100644
--- a/msa/js-executor/package.json
+++ b/msa/js-executor/package.json
@@ -1,7 +1,7 @@
{
"name": "thingsboard-js-executor",
"private": true,
- "version": "4.2.2.4",
+ "version": "4.2.2.5",
"description": "ThingsBoard JavaScript Executor Microservice",
"main": "server.ts",
"bin": "server.js",
diff --git a/msa/js-executor/pom.xml b/msa/js-executor/pom.xml
index f6f7961d0e..ca09388c19 100644
--- a/msa/js-executor/pom.xml
+++ b/msa/js-executor/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
msa
org.thingsboard.msa
diff --git a/msa/monitoring/pom.xml b/msa/monitoring/pom.xml
index 64157d6197..451150aafc 100644
--- a/msa/monitoring/pom.xml
+++ b/msa/monitoring/pom.xml
@@ -22,7 +22,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
msa
diff --git a/msa/pom.xml b/msa/pom.xml
index 0847add29e..edaecf7223 100644
--- a/msa/pom.xml
+++ b/msa/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
thingsboard
msa
diff --git a/msa/tb-node/pom.xml b/msa/tb-node/pom.xml
index 9be443d031..70c12c90c1 100644
--- a/msa/tb-node/pom.xml
+++ b/msa/tb-node/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
msa
org.thingsboard.msa
diff --git a/msa/tb/pom.xml b/msa/tb/pom.xml
index ba18c5279b..7cdda058e3 100644
--- a/msa/tb/pom.xml
+++ b/msa/tb/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
msa
org.thingsboard.msa
diff --git a/msa/transport/coap/pom.xml b/msa/transport/coap/pom.xml
index f78e2f0f13..02b8a665b2 100644
--- a/msa/transport/coap/pom.xml
+++ b/msa/transport/coap/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard.msa
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
org.thingsboard.msa.transport
diff --git a/msa/transport/http/pom.xml b/msa/transport/http/pom.xml
index ac25949c82..322e40f366 100644
--- a/msa/transport/http/pom.xml
+++ b/msa/transport/http/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard.msa
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
org.thingsboard.msa.transport
diff --git a/msa/transport/lwm2m/pom.xml b/msa/transport/lwm2m/pom.xml
index 89e99f79e2..018afb6f23 100644
--- a/msa/transport/lwm2m/pom.xml
+++ b/msa/transport/lwm2m/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard.msa
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
org.thingsboard.msa.transport
diff --git a/msa/transport/mqtt/pom.xml b/msa/transport/mqtt/pom.xml
index eb69201745..0eac380740 100644
--- a/msa/transport/mqtt/pom.xml
+++ b/msa/transport/mqtt/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard.msa
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
org.thingsboard.msa.transport
diff --git a/msa/transport/pom.xml b/msa/transport/pom.xml
index 399d84763c..726d5fdb13 100644
--- a/msa/transport/pom.xml
+++ b/msa/transport/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
msa
org.thingsboard.msa
diff --git a/msa/transport/snmp/pom.xml b/msa/transport/snmp/pom.xml
index 330e205394..55e1f03df4 100644
--- a/msa/transport/snmp/pom.xml
+++ b/msa/transport/snmp/pom.xml
@@ -21,7 +21,7 @@
org.thingsboard.msa
transport
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
org.thingsboard.msa.transport
diff --git a/msa/vc-executor-docker/pom.xml b/msa/vc-executor-docker/pom.xml
index fc8779250a..0c4c528f1a 100644
--- a/msa/vc-executor-docker/pom.xml
+++ b/msa/vc-executor-docker/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
msa
org.thingsboard.msa
diff --git a/msa/vc-executor/pom.xml b/msa/vc-executor/pom.xml
index 4bb404284a..c09b0dbb7f 100644
--- a/msa/vc-executor/pom.xml
+++ b/msa/vc-executor/pom.xml
@@ -21,7 +21,7 @@
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
msa
org.thingsboard.msa
diff --git a/msa/web-ui/package.json b/msa/web-ui/package.json
index e5acd2a6fa..4b1e489783 100644
--- a/msa/web-ui/package.json
+++ b/msa/web-ui/package.json
@@ -1,7 +1,7 @@
{
"name": "thingsboard-web-ui",
"private": true,
- "version": "4.2.2.4",
+ "version": "4.2.2.5",
"description": "ThingsBoard Web UI Microservice",
"main": "server.ts",
"bin": "server.js",
diff --git a/msa/web-ui/pom.xml b/msa/web-ui/pom.xml
index 738118d4f8..79996bfdd4 100644
--- a/msa/web-ui/pom.xml
+++ b/msa/web-ui/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
msa
org.thingsboard.msa
diff --git a/netty-mqtt/pom.xml b/netty-mqtt/pom.xml
index 9cc1f94bbe..cdcd9ef078 100644
--- a/netty-mqtt/pom.xml
+++ b/netty-mqtt/pom.xml
@@ -19,11 +19,11 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
thingsboard
netty-mqtt
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
jar
Netty MQTT Client
diff --git a/pom.xml b/pom.xml
index 680da381d9..ecc5870817 100755
--- a/pom.xml
+++ b/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
pom
Thingsboard
diff --git a/rest-client/pom.xml b/rest-client/pom.xml
index ceadf1d118..3e07db05d5 100644
--- a/rest-client/pom.xml
+++ b/rest-client/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
thingsboard
rest-client
diff --git a/rule-engine/pom.xml b/rule-engine/pom.xml
index 75bd4e06ed..d2a7afffd9 100644
--- a/rule-engine/pom.xml
+++ b/rule-engine/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
thingsboard
rule-engine
diff --git a/rule-engine/rule-engine-api/pom.xml b/rule-engine/rule-engine-api/pom.xml
index f45cd15c34..3112a8ba8c 100644
--- a/rule-engine/rule-engine-api/pom.xml
+++ b/rule-engine/rule-engine-api/pom.xml
@@ -22,7 +22,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
rule-engine
org.thingsboard.rule-engine
diff --git a/rule-engine/rule-engine-components/pom.xml b/rule-engine/rule-engine-components/pom.xml
index c6c2429a4f..9bce009263 100644
--- a/rule-engine/rule-engine-components/pom.xml
+++ b/rule-engine/rule-engine-components/pom.xml
@@ -22,7 +22,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
rule-engine
org.thingsboard.rule-engine
diff --git a/tools/pom.xml b/tools/pom.xml
index 86a17be7a5..35de3d7584 100644
--- a/tools/pom.xml
+++ b/tools/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
thingsboard
tools
diff --git a/transport/coap/pom.xml b/transport/coap/pom.xml
index cf4374ad9e..65b9af146d 100644
--- a/transport/coap/pom.xml
+++ b/transport/coap/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
org.thingsboard.transport
diff --git a/transport/http/pom.xml b/transport/http/pom.xml
index d5ff0be961..2bbe2277cf 100644
--- a/transport/http/pom.xml
+++ b/transport/http/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
org.thingsboard.transport
diff --git a/transport/lwm2m/pom.xml b/transport/lwm2m/pom.xml
index 1d0fe86220..8229e4d7d5 100644
--- a/transport/lwm2m/pom.xml
+++ b/transport/lwm2m/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
org.thingsboard.transport
diff --git a/transport/mqtt/pom.xml b/transport/mqtt/pom.xml
index e1c9512d05..3f84fd44d0 100644
--- a/transport/mqtt/pom.xml
+++ b/transport/mqtt/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
org.thingsboard.transport
diff --git a/transport/pom.xml b/transport/pom.xml
index 16052972cd..b3279b32ed 100644
--- a/transport/pom.xml
+++ b/transport/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
thingsboard
transport
diff --git a/transport/snmp/pom.xml b/transport/snmp/pom.xml
index cc18e3a815..d6f763a8a5 100644
--- a/transport/snmp/pom.xml
+++ b/transport/snmp/pom.xml
@@ -21,7 +21,7 @@
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
transport
diff --git a/ui-ngx/package.json b/ui-ngx/package.json
index 023ede7bd1..5358528a6b 100644
--- a/ui-ngx/package.json
+++ b/ui-ngx/package.json
@@ -1,6 +1,6 @@
{
"name": "thingsboard",
- "version": "4.2.2.4",
+ "version": "4.2.2.5",
"scripts": {
"ng": "ng",
"start": "node --max_old_space_size=8048 ./node_modules/@angular/cli/bin/ng serve --configuration development --host 0.0.0.0 --open",
diff --git a/ui-ngx/pom.xml b/ui-ngx/pom.xml
index 099850fb80..9d4ec3f656 100644
--- a/ui-ngx/pom.xml
+++ b/ui-ngx/pom.xml
@@ -20,7 +20,7 @@
4.0.0
org.thingsboard
- 4.2.2.4-SNAPSHOT
+ 4.2.2.5-SNAPSHOT
thingsboard
org.thingsboard