apache / apache/iceberg

[Bug]: GCPProperties and AzureProperties throw NumberFormatException on null property values

Open Beginner friendly
#17,771 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
9.2k
Forks
3.5k
Avg merge
2d 16h
Merged PRs (30d)
129

Description

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

Contributor guide

Open the contributing guide

Research direction

Start with GCPProperties.java and AzureProperties.java, then read PropertyUtil.propertyAsNullableInt and PropertyUtil.propertyAsNullableLong to compare the existing nullable parsing behavior. Reproduce the null-valued property cases and run the regression tests mentioned in the issue; done means both classes safely treat optional null numeric values as absent without changing valid-value parsing.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, gcp, java
Domain
cloud
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.