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

   **Apache Iceberg version**
   main @ 8550723a7
   
   **Query engine**
   Flink
   
   **Please describe the bug**
   `ExpireSnapshots.Builder.config()` throws `NullPointerException` when 
`flink-maintenance.expire-snapshots.retain-last` is not set 
(`flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/ExpireSnapshots.java`
 line 119).
   
   `ExpireSnapshotsConfig.retainLast()` returns `Integer` and is null when the 
option is unset: `RETAIN_LAST_OPTION` is declared `.intType().noDefaultValue()` 
and the getter uses `parseOptional()`. The option is not registered as a table 
property, so null is the only default state — `TestExpireSnapshotsConfig` 
asserts `assertThat(config.retainLast()).isNull()` for a default config. 
`config()` passes that value straight to `retainLast(int)`, which unboxes it.
   
   The sibling `ConvertEqualityDeletes.Builder.config()` 
(`ConvertEqualityDeletes.java` lines 136-144) already guards its nullable 
`scheduleOnIntervalSecond()` with a null check before calling the setter.
   
   **Steps to reproduce**
   Enable `flink-maintenance.expire-snapshots.enabled` without setting 
`retain-last`. `IcebergSink` (`IcebergSink.java` line 813) then calls 
`ExpireSnapshots.builder().config(config)` unconditionally.
   
   Expected: the builder keeps `numSnapshots` unset (its field is already 
`Integer`, defaulting to null).
   Actual:
   ```
   java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" 
because the return value of
   
"org.apache.iceberg.flink.maintenance.api.ExpireSnapshotsConfig.retainLast()" 
is null
        at 
org.apache.iceberg.flink.maintenance.api.ExpireSnapshots$Builder.config(ExpireSnapshots.java:119)
   ```
   
   **Additional context**
   N/A
   
   


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