From 44a7bf82c4156ef9bbfc1cd0364fe403f0afcfd9 Mon Sep 17 00:00:00 2001 From: Andrii Landiak Date: Mon, 17 Feb 2025 18:00:12 +0200 Subject: [PATCH] Fix ComponentLifecycleMsg: message and builder --- .../server/common/msg/plugin/ComponentLifecycleMsg.java | 4 ++++ .../org/thingsboard/server/common/util/ProtoUtils.java | 7 +++---- common/proto/src/main/proto/queue.proto | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/common/message/src/main/java/org/thingsboard/server/common/msg/plugin/ComponentLifecycleMsg.java b/common/message/src/main/java/org/thingsboard/server/common/msg/plugin/ComponentLifecycleMsg.java index 208b6ab2f5..7202a11a6c 100644 --- a/common/message/src/main/java/org/thingsboard/server/common/msg/plugin/ComponentLifecycleMsg.java +++ b/common/message/src/main/java/org/thingsboard/server/common/msg/plugin/ComponentLifecycleMsg.java @@ -26,6 +26,7 @@ import org.thingsboard.server.common.msg.MsgType; import org.thingsboard.server.common.msg.aware.TenantAwareMsg; import org.thingsboard.server.common.msg.cluster.ToAllNodesMsg; +import java.io.Serial; import java.util.Optional; /** @@ -33,6 +34,8 @@ import java.util.Optional; */ @Data public class ComponentLifecycleMsg implements TenantAwareMsg, ToAllNodesMsg { + + @Serial private static final long serialVersionUID = -5303421482781273062L; private final TenantId tenantId; @@ -66,4 +69,5 @@ public class ComponentLifecycleMsg implements TenantAwareMsg, ToAllNodesMsg { public MsgType getMsgType() { return MsgType.COMPONENT_LIFE_CYCLE_MSG; } + } diff --git a/common/proto/src/main/java/org/thingsboard/server/common/util/ProtoUtils.java b/common/proto/src/main/java/org/thingsboard/server/common/util/ProtoUtils.java index 07406977d2..057cf875f1 100644 --- a/common/proto/src/main/java/org/thingsboard/server/common/util/ProtoUtils.java +++ b/common/proto/src/main/java/org/thingsboard/server/common/util/ProtoUtils.java @@ -134,7 +134,7 @@ public class ProtoUtils { builder.setName(msg.getName()); } if (msg.getOldName() != null) { - builder.setName(msg.getOldName()); + builder.setOldName(msg.getOldName()); } return builder.build(); } @@ -149,8 +149,8 @@ public class ProtoUtils { .tenantId(TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB()))) .entityId(entityId) .event(ComponentLifecycleEvent.values()[proto.getEventValue()]) - .name(proto.getName()) - .oldName(proto.getOldName()); + .name(proto.hasName() ? proto.getName() : null) + .oldName(proto.hasOldName() ? proto.getOldName() : null); if (proto.getProfileIdMSB() != 0 || proto.getProfileIdLSB() != 0) { var profileType = EntityType.DEVICE.equals(entityId.getEntityType()) ? EntityType.DEVICE_PROFILE : EntityType.ASSET_PROFILE; builder.profileId(EntityIdFactory.getByTypeAndUuid(profileType, new UUID(proto.getProfileIdMSB(), proto.getProfileIdLSB()))); @@ -166,7 +166,6 @@ public class ProtoUtils { return entityTypeByProtoNumber[entityType.getNumber()]; } - public static TransportProtos.ToEdgeSyncRequestMsgProto toProto(ToEdgeSyncRequest request) { return TransportProtos.ToEdgeSyncRequestMsgProto.newBuilder() .setTenantIdMSB(request.getTenantId().getId().getMostSignificantBits()) diff --git a/common/proto/src/main/proto/queue.proto b/common/proto/src/main/proto/queue.proto index d0050c310d..e782291f02 100644 --- a/common/proto/src/main/proto/queue.proto +++ b/common/proto/src/main/proto/queue.proto @@ -1188,8 +1188,8 @@ message ComponentLifecycleMsgProto { int64 entityIdLSB = 5; ComponentLifecycleEvent event = 6; //Since 4.0. To replace the - string oldName = 7; - string name = 8; + optional string oldName = 7; + optional string name = 8; int64 oldProfileIdMSB = 9; int64 oldProfileIdLSB = 10; int64 profileIdMSB = 11;