asnowfox edited a comment on issue #2468:
URL: https://github.com/apache/iceberg/issues/2468#issuecomment-906226578


   I think I found the reason of this problem. in DynConstructors.java which 
borrowed from parquet-common, the ClassLoader in Builder is a loader of 
currentThread, looks like this
   ```
   public static class Builder {
       private final Class<?> baseClass;
       private ClassLoader loader = 
Thread.currentThread().getContextClassLoader();
       private Ctor ctor = null;
       private Map<String, Throwable> problems = new HashMap<String, 
Throwable>();
   
       public Builder(Class<?> baseClass) {
         this.baseClass = baseClass;
       }
   
       public Builder() {
         this.baseClass = null;
       }
   ......
   ```
   So,  when during runtime, the dynamic class is loaded by current thread, and 
the base class/interface is not  loaded by current thread. it will have the 
cast Exception.
   
   solution:
   ```
   public static class Builder {
       private final Class<?> baseClass;
       private ClassLoader loader = 
Thread.currentThread().getContextClassLoader();
       private Ctor ctor = null;
       private Map<String, Throwable> problems = new HashMap<String, 
Throwable>();
   
       public Builder(Class<?> baseClass) {
         this.baseClass = baseClass;
         this.loader = this.baseClass.getClassLoader();
       }
   
       public Builder() {
         this.baseClass = null;
       }
   ......
   ```
   


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