Prabal864 opened a new issue, #17771:
URL: https://github.com/apache/iceberg/issues/17771

   ### Apache Iceberg version
   
   main (development)
   
   ### Query engine
   
   Other
   
   ### Please describe the bug 🐞
   
   `GCPProperties` and `AzureProperties` throw `NumberFormatException` when 
optional numeric properties exist in the properties map with `null` values.
   
   #### Problem
   
   In `GCPProperties.java`:
   ```java
   if (properties.containsKey(GCS_CHANNEL_READ_CHUNK_SIZE)) {
     gcsChannelReadChunkSize = 
Integer.parseInt(properties.get(GCS_CHANNEL_READ_CHUNK_SIZE));
   }
   
   if (properties.containsKey(GCS_CHANNEL_WRITE_CHUNK_SIZE)) {
     gcsChannelWriteChunkSize = 
Integer.parseInt(properties.get(GCS_CHANNEL_WRITE_CHUNK_SIZE));
   }
   
   if (properties.containsKey(GCS_OAUTH2_TOKEN_EXPIRES_AT)) {
     gcsOAuth2TokenExpiresAt =
         new Date(Long.parseLong(properties.get(GCS_OAUTH2_TOKEN_EXPIRES_AT)));
   }
   ```
   
   In `AzureProperties.java`:
   ```java
   if (properties.containsKey(ADLS_READ_BLOCK_SIZE)) {
     this.adlsReadBlockSize = 
Integer.parseInt(properties.get(ADLS_READ_BLOCK_SIZE));
   }
   if (properties.containsKey(ADLS_WRITE_BLOCK_SIZE)) {
     this.adlsWriteBlockSize = 
Long.parseLong(properties.get(ADLS_WRITE_BLOCK_SIZE));
   }
   ```
   
   When configuration properties are merged or populated from frameworks (e.g. 
Spring Cloud, Hadoop/Spark configuration maps, or REST client dictionaries) 
containing entries mapped to `null`, `properties.containsKey(...)` evaluates to 
`true`. Calling `Integer.parseInt(null)` or `Long.parseLong(null)` results in:
   
   ```
   java.lang.NumberFormatException: Cannot parse null string
   ```
   
   #### Expected Behavior
   
   Optional numeric properties with `null` values in the configuration map 
should be treated safely as absent (`Optional.empty()`), consistent with how 
`PropertyUtil.propertyAsNullableInt` and `PropertyUtil.propertyAsNullableLong` 
operate across the rest of the codebase.
   
   #### Reproduction
   
   ```java
   Map<String, String> properties = new HashMap<>();
   properties.put(GCPProperties.GCS_CHANNEL_READ_CHUNK_SIZE, null);
   new GCPProperties(properties); // Throws NumberFormatException: Cannot parse 
null string
   ```
   
   #### Proposed Solution
   
   Update `GCPProperties` and `AzureProperties` to parse optional numeric 
fields via `PropertyUtil.propertyAsNullableInt` and 
`PropertyUtil.propertyAsNullableLong`.
   
   I have a working solution with regression tests ready in branch 
`Prabal864:fix/gcp-azure-properties-null-handling` and would be happy to open a 
PR for this once assigned.
   
   ### Willingness to contribute
   
   - [x] I can contribute a fix for this bug independently
   


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