stayrascal opened a new pull request #4920:
URL: https://github.com/apache/hudi/pull/4920


   …Properties.java
   
   ## *Tips*
   - *Thank you very much for contributing to Apache Hudi.*
   - *Please review https://hudi.apache.org/contribute/how-to-contribute before 
opening a pull request.*
   
   ## What is the purpose of the pull request
   
   I'm running Flink with Hudi in Java 11 environment(Even through I know Hudi 
might only support Java8/9/10), But we cannot change our JDK version. Based on 
this situation, We meet a NPE problem during 
`HoodieWriteConfig.getIndexType()`, but I test that it works in my local Java 8 
environment. It seems that we implemented a `TypedProperties` inherit 
`Properties`, and overwrite `stringPropertyNames` method & `put` method.
   
   There are some difference of `Properties.putAll(Map<?,?> t)` between Java 8 
and Java 11. 
   
   *Java 8*: `TypedProperties`  will use HashTable's `putAll` method, which 
will call `TypedProperties.put` which will add the incoming keys in 
`TypedProperties.keys`
   ```
   public synchronized void putAll(Map<? extends K, ? extends V> t) {
           for (Map.Entry<? extends K, ? extends V> e : t.entrySet())
               put(e.getKey(), e.getValue());
       }
   ```
   
   *Java 11*: `Properties` overwrite `putAll` method, and delegate the  
incoming map to `ConcurrentHashMap`. won't call `TypedProperties.put` anymore, 
which lead the `TypedProperties.keys` miss some keys, and then it cause we miss 
the `hoodie.index.type` configuration.
   ```
   @Override
       public synchronized void putAll(Map<?, ?> t) {
           map.putAll(t);
       }
   ```
   
   So we also need to overwrite `putAll` method to better  suitable high Java 
version runtime.
   
   ## Brief change log
   
     - *Overwrite `putAll` method in `TypedPropertis`*
     - *Add class type checking before convert to String hardly*
   
   ## Verify this pull request
   
   This change added tests and can be verified as follows:
   
     - *Add unit test case to test `putAll` cases in TestTypedProperties.java*
   
   ## Committer checklist
   
    - [ ] Has a corresponding JIRA in PR title & commit
    
    - [ ] Commit message is descriptive of the change
    
    - [ ] CI is green
   
    - [ ] Necessary doc changes done or have another open PR
          
    - [ ] For large changes, please consider breaking it into sub-tasks under 
an umbrella JIRA.
   


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


Reply via email to