diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/FlinkCatalogParams.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/FlinkCatalogParams.java index 329d87c35a..efd2d95cf2 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/FlinkCatalogParams.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/FlinkCatalogParams.java @@ -80,7 +80,7 @@ public static FlinkCatalogParams of(FlinkCatalog flinkCatalog) { } } catch (JsonProcessingException e) { log.error("Flink catalog params json read failed", e); - throw new RuntimeException(e); + throw new RuntimeException("Flink catalog params json read failed"); } return flinkCatalogParams; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkCatalog.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkCatalog.java index 350e901331..b8de5a2e55 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkCatalog.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkCatalog.java @@ -92,7 +92,7 @@ public static FlinkCatalog of(FlinkCatalogParams flinkCatalogParams) { } } catch (JsonProcessingException e) { log.error("Flink catalog json read failed", e); - throw new RuntimeException(e); + throw new RuntimeException("Flink catalog json read failed"); } return flinkCatalog; } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/CatalogServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/CatalogServiceImpl.java index ab100db4c2..199220fb06 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/CatalogServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/CatalogServiceImpl.java @@ -38,6 +38,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.regex.Pattern; /** catalog manage */ @Service @@ -47,6 +48,8 @@ public class CatalogServiceImpl extends ServiceImpl implements CatalogService { + private static final String CATALOG_REGEX = "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"; + @Override public boolean create(FlinkCatalogParams catalog, Long userId) { AlertException.throwIfNull( @@ -115,7 +118,6 @@ public Boolean existsByCatalogName(String catalogName) { /** validate catalog name */ private boolean validateCatalogName(String catalogName) { - String regex = "^(?:[a-z0-9]+[-\\.]?)*(?:[a-z0-9]+)$"; - return catalogName.matches(regex); + return Pattern.compile(CATALOG_REGEX).matcher(catalogName).matches(); } }