yuqi1129 commented on code in PR #13214:
URL: https://github.com/apache/gravitino/pull/13214#discussion_r4026774018
##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/utils/FactoryUtils.java:
##########
@@ -51,7 +56,42 @@ private FactoryUtils() {}
GravitinoPaimonCatalogFactoryOptions.IDENTIFIER);
public static boolean isGravitinoManagedCatalogType(String type) {
- return GRAVITINO_CATALOG_TYPES.contains(type);
+ return GRAVITINO_CATALOG_TYPES.contains(type) ||
isProvidedByCatalogFactory(type);
+ }
+
+ /**
+ * Whether a {@link BaseCatalogFactory} on the classpath declares the type.
This lets a jar
+ * outside the connector contribute catalog types without registering them
here.
+ */
+ private static boolean isProvidedByCatalogFactory(String type) {
+ if (type == null) {
+ return false;
+ }
+ return
isProvidedByCatalogFactory(ServiceLoader.load(Factory.class).iterator(), type);
+ }
+
+ @VisibleForTesting
+ static boolean isProvidedByCatalogFactory(Iterator<Factory> factories,
String type) {
+ // Both hasNext() and next() may fail on a broken service entry, so both
stay inside the try.
Review Comment:
If `hasNext()` throw a throwable, the loop will not break forever.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]