jackye1995 commented on a change in pull request #2333:
URL: https://github.com/apache/iceberg/pull/2333#discussion_r594571232
##########
File path: core/src/main/java/org/apache/iceberg/CatalogUtil.java
##########
@@ -215,16 +216,27 @@ public static FileIO loadFileIO(
Configuration hadoopConf) {
LOG.info("Loading custom FileIO implementation: {}", impl);
DynConstructors.Ctor<FileIO> ctor;
+ boolean useNoArgConstructor = true;
try {
ctor = DynConstructors.builder(FileIO.class).impl(impl).buildChecked();
} catch (NoSuchMethodException e) {
- throw new IllegalArgumentException(String.format(
- "Cannot initialize FileIO, missing no-arg constructor: %s", impl),
e);
+ LOG.error("No-arg constructor not found for {}, try to use Hadoop
Configuration constructor", impl, e);
+ try {
+ ctor = DynConstructors.builder(Catalog.class).impl(impl,
Configuration.class).buildChecked();
+ useNoArgConstructor = false;
Review comment:
> do we always want the 0 arg constructor to get priority over a 1-arg
I think it is better to let 0 arg constructor to get priority, so it does
not block any FileIO that might have both constructors.
> To avoid try nesting we could extract that to a helper function
Yeah I tried about that but there was duplicated logic for finding
ClassCastException. Using a helper function is probably a way to solve it, let
me update with that, thank you!
----------------------------------------------------------------
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]