updated check for single value argument size
This commit is contained in:
parent
7600401b86
commit
93090af2ee
@ -301,7 +301,7 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM
|
||||
}
|
||||
}
|
||||
|
||||
private void removeStateAndRaiseSizeException(CalculatedFieldEntityCtxId ctxId, CalculatedFieldException ex, TbCallback callback) {
|
||||
private void removeStateAndRaiseSizeException(CalculatedFieldEntityCtxId ctxId, CalculatedFieldException ex, TbCallback callback) throws CalculatedFieldException {
|
||||
// We remove the state, but remember that it is over-sized in a local map.
|
||||
cfStateService.removeState(ctxId, new TbCallback() {
|
||||
@Override
|
||||
@ -314,6 +314,7 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM
|
||||
callback.onFailure(ex);
|
||||
}
|
||||
});
|
||||
throw ex;
|
||||
}
|
||||
|
||||
private Map<String, ArgumentEntry> mapToArguments(CalculatedFieldCtx ctx, List<TsKvProto> data) {
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
package org.thingsboard.server.actors.calculatedField;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.thingsboard.common.util.DebugModeUtil;
|
||||
import org.thingsboard.server.actors.ActorSystemContext;
|
||||
import org.thingsboard.server.actors.TbActorCtx;
|
||||
import org.thingsboard.server.actors.TbActorRef;
|
||||
@ -51,8 +50,6 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import static org.thingsboard.server.utils.CalculatedFieldUtils.fromProto;
|
||||
|
||||
@ -117,11 +117,6 @@ public class DefaultCalculatedFieldCache implements CalculatedFieldCache {
|
||||
CalculatedField calculatedField = getCalculatedField(calculatedFieldId);
|
||||
if (calculatedField != null) {
|
||||
ctx = new CalculatedFieldCtx(calculatedField, tbelInvokeService, apiLimitService);
|
||||
try {
|
||||
ctx.init();
|
||||
} catch (Exception e) {
|
||||
log.warn("Failed to initialize CF context.");
|
||||
}
|
||||
calculatedFieldsCtx.put(calculatedFieldId, ctx);
|
||||
log.debug("[{}] Put calculated field ctx into cache: {}", calculatedFieldId, ctx);
|
||||
}
|
||||
|
||||
@ -91,8 +91,10 @@ public abstract class BaseCalculatedFieldState implements CalculatedFieldState {
|
||||
if (entry instanceof TsRollingArgumentEntry) {
|
||||
return;
|
||||
}
|
||||
if (ctx.getMaxSingleValueArgumentSize() > 0 && toSingleValueArgumentProto(name, (SingleValueArgumentEntry) entry).getSerializedSize() > ctx.getMaxSingleValueArgumentSize()) {
|
||||
throw new IllegalArgumentException("Single value size exceeds the maximum allowed limit. The argument will not be used for calculation.");
|
||||
if (entry instanceof SingleValueArgumentEntry singleValueArgumentEntry) {
|
||||
if (ctx.getMaxSingleValueArgumentSize() > 0 && toSingleValueArgumentProto(name, singleValueArgumentEntry).getSerializedSize() > ctx.getMaxSingleValueArgumentSize()) {
|
||||
throw new IllegalArgumentException("Single value size exceeds the maximum allowed limit. The argument will not be used for calculation.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user