Merge pull request #11661 from YevhenBondarenko/fix/subscription-service-npe

fixed NPE in subscription service after restart
This commit is contained in:
Andrew Shvayka 2024-09-16 16:51:57 +03:00 committed by GitHub
commit da2e099307
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -334,7 +334,7 @@ public class DefaultTbLocalSubscriptionService implements TbLocalSubscriptionSer
} }
private void onTimeSeriesUpdate(UUID entityId, List<TsKvEntry> data, TbCallback callback) { private void onTimeSeriesUpdate(UUID entityId, List<TsKvEntry> data, TbCallback callback) {
entityUpdates.get(entityId).timeSeriesUpdateTs = System.currentTimeMillis(); getEntityUpdatesInfo(entityId).timeSeriesUpdateTs = System.currentTimeMillis();
processSubscriptionData(entityId, processSubscriptionData(entityId,
sub -> TbSubscriptionType.TIMESERIES.equals(sub.getType()), sub -> TbSubscriptionType.TIMESERIES.equals(sub.getType()),
s -> { s -> {
@ -371,7 +371,7 @@ public class DefaultTbLocalSubscriptionService implements TbLocalSubscriptionSer
} }
private void onAttributesUpdate(UUID entityId, String scope, List<TsKvEntry> data, TbCallback callback) { private void onAttributesUpdate(UUID entityId, String scope, List<TsKvEntry> data, TbCallback callback) {
entityUpdates.get(entityId).attributesUpdateTs = System.currentTimeMillis(); getEntityUpdatesInfo(entityId).attributesUpdateTs = System.currentTimeMillis();
processSubscriptionData(entityId, processSubscriptionData(entityId,
sub -> TbSubscriptionType.ATTRIBUTES.equals(sub.getType()), sub -> TbSubscriptionType.ATTRIBUTES.equals(sub.getType()),
s -> { s -> {
@ -639,4 +639,8 @@ public class DefaultTbLocalSubscriptionService implements TbLocalSubscriptionSer
throw new TbRateLimitsException(message); throw new TbRateLimitsException(message);
} }
private TbEntityUpdatesInfo getEntityUpdatesInfo(UUID entityId) {
return entityUpdates.computeIfAbsent(entityId, id -> new TbEntityUpdatesInfo(0));
}
} }