RocMarshal commented on code in PR #3647:
URL: 
https://github.com/apache/incubator-streampark/pull/3647#discussion_r1545916604


##########
streampark-flink/streampark-flink-sql-gateway/streampark-flink-sql-gateway-base/src/main/java/org/apache/streampark/gateway/factories/FactoryUtil.java:
##########
@@ -48,47 +48,44 @@ public static <T extends Factory> T discoverFactory(
             .filter(f -> factoryClass.isAssignableFrom(f.getClass()))
             .collect(Collectors.toList());
 
-    if (foundFactories.isEmpty()) {
-      throw new ValidationException(
-          String.format(
-              "Could not find any factories that implement '%s' in the 
classpath.",
-              factoryClass.getName()));
-    }
+    AssertUtils.required(
+        !foundFactories.isEmpty(),
+        String.format(
+            "Could not find any factories that implement '%s' in the 
classpath.",
+            factoryClass.getName()));
 
     final List<Factory> matchingFactories =
         foundFactories.stream()
             .filter(f -> f.factoryIdentifier().equals(factoryIdentifier))
             .collect(Collectors.toList());
 
-    if (matchingFactories.isEmpty()) {
-      throw new ValidationException(
-          String.format(
-              "Could not find any factory for identifier '%s' that implements 
'%s' in the classpath.%n%n"
-                  + "Available factory identifiers are:%n%n"
-                  + "%s",
-              factoryIdentifier,
-              factoryClass.getName(),
-              foundFactories.stream()
-                  .map(Factory::factoryIdentifier)
-                  .filter(identifier -> !DEFAULT_IDENTIFIER.equals(identifier))
-                  .distinct()
-                  .sorted()
-                  .collect(Collectors.joining("\n"))));
-    }
-    if (matchingFactories.size() > 1) {
-      throw new ValidationException(
-          String.format(
-              "Multiple factories for identifier '%s' that implement '%s' 
found in the classpath.\n\n"
-                  + "Ambiguous factory classes are:\n\n"
-                  + "%s",
-              factoryIdentifier,
-              factoryClass.getName(),
-              matchingFactories.stream()
-                  .map(f -> f.getClass().getName())
-                  .sorted()
-                  .collect(Collectors.joining("\n"))));
-    }
+    AssertUtils.required(
+        !matchingFactories.isEmpty(),

Review Comment:
   There's a un-matched semantic replacement.
   The  original potential  Exception is `ValidationException` but the it's 
`IllegalArgumentxx` exception.
   
   Would you mind checking the whole corresponding changed lines about 
exception-matched ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@streampark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to