rdblue commented on a change in pull request #3906:
URL: https://github.com/apache/iceberg/pull/3906#discussion_r786244912
##########
File path: core/src/main/java/org/apache/iceberg/avro/Avro.java
##########
@@ -553,15 +558,20 @@ public static ReadBuilder read(InputFile file) {
public static class ReadBuilder {
private final InputFile file;
private final Map<String, String> renames = Maps.newLinkedHashMap();
- private ClassLoader loader =
Thread.currentThread().getContextClassLoader();
+ private ClassLoader loader = null;
private NameMapping nameMapping;
private boolean reuseContainers = false;
private org.apache.iceberg.Schema schema = null;
private Function<Schema, DatumReader<?>> createReaderFunc = null;
private BiFunction<org.apache.iceberg.Schema, Schema, DatumReader<?>>
createReaderBiFunc = null;
private final Function<Schema, DatumReader<?>> defaultCreateReaderFunc =
readSchema -> {
GenericAvroReader<?> reader = new GenericAvroReader<>(readSchema);
- reader.setClassLoader(loader);
+ ClassLoader classLoader = loader;
+ if (classLoader == null) {
+ LOG.warn("Classloader for avro reader not set, use the thread context
classloader.");
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+ reader.setClassLoader(classLoader);
Review comment:
I don't think that we need to change any behavior in this class. The
current behavior is adequate and setting the classloader is only needed if you
are attempting to load a custom class or if the context classloader throws an
unexpected exception, as in the Flink case.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]