diqiu50 commented on code in PR #13214:
URL: https://github.com/apache/gravitino/pull/13214#discussion_r4026549675
##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/utils/FactoryUtils.java:
##########
@@ -51,7 +55,33 @@ 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;
+ }
+ Iterator<Factory> iterator = ServiceLoader.load(Factory.class).iterator();
+ while (true) {
+ try {
+ if (!iterator.hasNext()) {
Review Comment:
hasNext() itself throws ServiceConfigurationError when a service entry names
a class that is missing, so it has to sit inside the try as well; added a
comment to make that explicit.
--
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]