diff --git a/msg-center-api/src/main/java/cn/axzo/msg/center/service/pending/ModelVersion.java b/msg-center-api/src/main/java/cn/axzo/msg/center/service/pending/ModelVersion.java index d5292a9a..f72ebf0e 100644 --- a/msg-center-api/src/main/java/cn/axzo/msg/center/service/pending/ModelVersion.java +++ b/msg-center-api/src/main/java/cn/axzo/msg/center/service/pending/ModelVersion.java @@ -1,7 +1,6 @@ package cn.axzo.msg.center.service.pending; import cn.axzo.framework.domain.ServiceException; -import com.microsoft.schemas.office.x2006.encryption.STSaltSize; import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -19,6 +18,7 @@ public class ModelVersion { private static final Map VERSIONS = new ConcurrentHashMap<>(); private static final Integer MAX_VERSION_NUMBER = 500; + private static final Integer MIN_VERSION_NUMBER = -1; public static final ModelVersion V2 = of(null); public static final ModelVersion V3 = of(3); @@ -28,9 +28,7 @@ public class ModelVersion { public static ModelVersion of(Integer version) { // attack? - if (version != null - && version > MAX_VERSION_NUMBER - && version < Integer.MAX_VALUE) + if (version != null && (version > MAX_VERSION_NUMBER || version < MIN_VERSION_NUMBER)) throw new ServiceException("model version is too large"); if (version == null) version = Integer.MIN_VALUE; return VERSIONS.computeIfAbsent(version, ModelVersion::new);