fix NPE (skip usage state messages for deleted tenants)

This commit is contained in:
YevhenBondarenko 2020-12-02 18:27:26 +02:00
parent 0f26bb4894
commit 1a237a9843
2 changed files with 6 additions and 1 deletions

View File

@ -147,6 +147,11 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService {
public void process(TbProtoQueueMsg<ToUsageStatsServiceMsg> msg, TbCallback callback) {
ToUsageStatsServiceMsg statsMsg = msg.getValue();
TenantId tenantId = new TenantId(new UUID(statsMsg.getTenantIdMSB(), statsMsg.getTenantIdLSB()));
if (tenantProfileCache.get(tenantId) == null) {
return;
}
TenantApiUsageState tenantState;
List<TsKvEntry> updatedEntries;
Map<ApiFeature, ApiUsageStateValue> result;

View File

@ -297,7 +297,7 @@ public class DefaultTbCoreConsumerService extends AbstractConsumerService<ToCore
try {
handleUsageStats(msg, callback);
} catch (Throwable e) {
log.warn("[{}] Failed to process usge stats: {}", id, msg, e);
log.warn("[{}] Failed to process usage stats: {}", id, msg, e);
callback.onFailure(e);
}
});