rymurr commented on a change in pull request #2146:
URL: https://github.com/apache/iceberg/pull/2146#discussion_r564261743
##########
File path: core/src/main/java/org/apache/iceberg/CatalogUtil.java
##########
@@ -129,6 +129,35 @@ private static void deleteFiles(FileIO io,
Set<ManifestFile> allManifests) {
});
}
+ /**
+ * Get constructor for Catalog from impl. Impl must be valid class name and
have zero-arg constructor.
+ *
+ * <p>We try to get the constructor for impl and if we fail we check for
common error patterns. Specifically:
+ * a ClassNotFoundException for an invalid impl String and a
NoClassDefFoundError if impl fails to get initialized.
+ * Otherwise the original exception is passed up and the error is assumed to
be a missing no-args constructor.
+ *
+ * @param impl catalog implementation full class name
+ * @return constructor for catalog implementation impl
+ * @throws IllegalArgumentException if no-arg constructor not found or error
during initialization
+ */
+ private static DynConstructors.Ctor<Catalog> getCatalogConstructor(String
impl) {
+ DynConstructors.Ctor<Catalog> ctor;
+ DynConstructors.Builder ctorBuilder =
DynConstructors.builder(Catalog.class).impl(impl);
+ try {
+ ctor = ctorBuilder.buildChecked();
+ } catch (NoSuchMethodException e) {
+ Throwable originalError = ctorBuilder.problems().getOrDefault(impl, e);
+ String message = String.format("Cannot initialize Catalog, missing
no-arg constructor: %s", impl);
Review comment:
I suspect no-arg constructor is likely to be the most common error.
'Cannot be initialized' is related to classpath issues only. I have updated to
remove the dup message.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]