From d024c69a0cfcd37c2d39d2e7c0e30cee53dc038c Mon Sep 17 00:00:00 2001 From: YevhenBondarenko Date: Tue, 30 Nov 2021 12:50:02 +0200 Subject: [PATCH] improvements (remove security if a new device profile has been set) --- .../lwm2m/server/uplink/DefaultLwM2MUplinkMsgHandler.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/uplink/DefaultLwM2MUplinkMsgHandler.java b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/uplink/DefaultLwM2MUplinkMsgHandler.java index dc96b1a9d2..3a24a19d9b 100644 --- a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/uplink/DefaultLwM2MUplinkMsgHandler.java +++ b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/uplink/DefaultLwM2MUplinkMsgHandler.java @@ -392,12 +392,14 @@ public class DefaultLwM2MUplinkMsgHandler extends LwM2MExecutorAwareService impl } @Override - public void onDeviceUpdate(SessionInfoProto sessionInfo, Device device, Optional deviceProfileOpt) { + public void onDeviceUpdate(SessionInfoProto sessionInfo, Device device, Optional newDeviceProfileOpt) { try { LwM2mClient client = clientContext.getClientByDeviceId(device.getUuidId()); if (client != null) { - this.securityStore.remove(client.getEndpoint(), client.getRegistration().getId()); - this.onDeviceUpdate(client, device, deviceProfileOpt); + if (newDeviceProfileOpt.isPresent()) { + this.securityStore.remove(client.getEndpoint(), client.getRegistration().getId()); + } + this.onDeviceUpdate(client, device, newDeviceProfileOpt); } } catch (Exception e) { log.warn("[{}] failed to update device: {}", device.getId(), device);