From faa8d15315a802553c6a261770e3cd7fa8d23640 Mon Sep 17 00:00:00 2001 From: zlucelia <66543456+Zhao-LX2000@users.noreply.github.com> Date: Thu, 17 Aug 2023 11:14:08 +0800 Subject: [PATCH] fix: correct the length check of cluster label (#4865) --- .../linkis/manager/label/entity/cluster/ClusterLabel.java | 6 +++--- .../label/errorcode/LabelCommonErrorCodeSummary.java | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/entity/cluster/ClusterLabel.java b/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/entity/cluster/ClusterLabel.java index fa7708d7ff..05754c6536 100644 --- a/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/entity/cluster/ClusterLabel.java +++ b/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/entity/cluster/ClusterLabel.java @@ -26,7 +26,7 @@ import java.util.HashMap; -import static org.apache.linkis.manager.label.errorcode.LabelCommonErrorCodeSummary.LABEL_ERROR_CODE; +import static org.apache.linkis.manager.label.errorcode.LabelCommonErrorCodeSummary.CLUSTER_LABEL_VALUE_ERROR; public class ClusterLabel extends GenericLabel implements EngineNodeLabel, UserModifiable { @@ -86,9 +86,9 @@ public boolean equals(Object other) { @Override public void valueCheck(String stringValue) throws LabelErrorException { if (!StringUtils.isEmpty(stringValue)) { - if (stringValue.split(SerializableLabel.VALUE_SEPARATOR).length != 1) { + if (stringValue.split(SerializableLabel.VALUE_SEPARATOR).length != 2) { throw new LabelErrorException( - LABEL_ERROR_CODE.getErrorCode(), LABEL_ERROR_CODE.getErrorDesc()); + CLUSTER_LABEL_VALUE_ERROR.getErrorCode(), CLUSTER_LABEL_VALUE_ERROR.getErrorDesc()); } } } diff --git a/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/errorcode/LabelCommonErrorCodeSummary.java b/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/errorcode/LabelCommonErrorCodeSummary.java index a0ebdffe8a..322eb5af86 100644 --- a/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/errorcode/LabelCommonErrorCodeSummary.java +++ b/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/errorcode/LabelCommonErrorCodeSummary.java @@ -31,7 +31,9 @@ public enum LabelCommonErrorCodeSummary implements LinkisErrorCode { CHECK_LABEL_REMOVE_REQUEST( 25007, "ServiceInstance in request is null, please check label remove request(请求中的 ServiceInstance 为空,请检查标签删除请求)"), - CHECK_LABEL_VALUE_EMPTY(25008, "Label value cannot be empty"); + CHECK_LABEL_VALUE_EMPTY(25008, "Label value cannot be empty"), + CLUSTER_LABEL_VALUE_ERROR( + 25009, "The value of cluster label should have a length of 2 and be separated by '-' "); /** (errorCode)错误码 */ private final int errorCode;