yittg commented on a change in pull request #3906:
URL: https://github.com/apache/iceberg/pull/3906#discussion_r786373533



##########
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:
       Adding warning mainly to prevent forgetting to set classloader if 
required. I've to permit that it is not perfect, but have no better idea.
   It's ok to not change the behavior of this class.
   
   I'll remove changes in this file.
   
   




-- 
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]

Reply via email to