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

fix NPE (skip usage state messages for deleted tenants)
This commit is contained in:
Igor Kulikov 2020-12-02 18:40:34 +02:00 committed by GitHub
commit b4ae7e37d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) { public void process(TbProtoQueueMsg<ToUsageStatsServiceMsg> msg, TbCallback callback) {
ToUsageStatsServiceMsg statsMsg = msg.getValue(); ToUsageStatsServiceMsg statsMsg = msg.getValue();
TenantId tenantId = new TenantId(new UUID(statsMsg.getTenantIdMSB(), statsMsg.getTenantIdLSB())); TenantId tenantId = new TenantId(new UUID(statsMsg.getTenantIdMSB(), statsMsg.getTenantIdLSB()));
if (tenantProfileCache.get(tenantId) == null) {
return;
}
TenantApiUsageState tenantState; TenantApiUsageState tenantState;
List<TsKvEntry> updatedEntries; List<TsKvEntry> updatedEntries;
Map<ApiFeature, ApiUsageStateValue> result; Map<ApiFeature, ApiUsageStateValue> result;

View File

@ -297,7 +297,7 @@ public class DefaultTbCoreConsumerService extends AbstractConsumerService<ToCore
try { try {
handleUsageStats(msg, callback); handleUsageStats(msg, callback);
} catch (Throwable e) { } 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); callback.onFailure(e);
} }
}); });