Commit b4ae7e37d6bda36b4d4c8699c12bfcf5c5a27b15

Authored by Igor Kulikov
Committed by GitHub
2 parents 0f26bb48 1a237a98

Merge pull request #3798 from YevhenBondarenko/fix-api-usage

fix NPE (skip usage state messages for deleted tenants)
... ... @@ -147,6 +147,11 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService {
147 147 public void process(TbProtoQueueMsg<ToUsageStatsServiceMsg> msg, TbCallback callback) {
148 148 ToUsageStatsServiceMsg statsMsg = msg.getValue();
149 149 TenantId tenantId = new TenantId(new UUID(statsMsg.getTenantIdMSB(), statsMsg.getTenantIdLSB()));
  150 +
  151 + if (tenantProfileCache.get(tenantId) == null) {
  152 + return;
  153 + }
  154 +
150 155 TenantApiUsageState tenantState;
151 156 List<TsKvEntry> updatedEntries;
152 157 Map<ApiFeature, ApiUsageStateValue> result;
... ...
... ... @@ -297,7 +297,7 @@ public class DefaultTbCoreConsumerService extends AbstractConsumerService<ToCore
297 297 try {
298 298 handleUsageStats(msg, callback);
299 299 } catch (Throwable e) {
300   - log.warn("[{}] Failed to process usge stats: {}", id, msg, e);
  300 + log.warn("[{}] Failed to process usage stats: {}", id, msg, e);
301 301 callback.onFailure(e);
302 302 }
303 303 });
... ...