Copilot commented on code in PR #13214:
URL: https://github.com/apache/gravitino/pull/13214#discussion_r4025475140
##########
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()) {
+ return false;
Review Comment:
The new ServiceLoader path is not exercised by the added tests: they cover
only the hard-coded identifiers, missing identifiers, and null, while the test
classpath has no `BaseCatalogFactory` provider. Please add a test
provider/service entry (or an injectable loader) that verifies an external
factory identifier is recognized and that a provider throwing
`ServiceConfigurationError`/`LinkageError` is skipped; otherwise the behavior
this PR introduces can regress without detection.
--
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]