Flink: Fix NPE in ExpireSnapshots config when retain-last is unset#17277
Draft
thswlsqls wants to merge 1 commit into
Draft
Flink: Fix NPE in ExpireSnapshots config when retain-last is unset#17277thswlsqls wants to merge 1 commit into
thswlsqls wants to merge 1 commit into
Conversation
ExpireSnapshots.Builder.config() passed the nullable ExpireSnapshotsConfig.retainLast() to retainLast(int), which unboxed null and threw. The retain-last option has no default and is not backed by a table property, so an unset value is the normal state and enabling expire-snapshots maintenance without it always failed. Call the setter only when the value is present, leaving the builder's numSnapshots unset otherwise. This mirrors ConvertEqualityDeletes.Builder.config(), which already guards its nullable scheduleOnIntervalSecond(). Generated-by: Claude Code
thswlsqls
marked this pull request as draft
July 17, 2026 11:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #17275
Summary
ExpireSnapshots.Builder.config()passed the nullableExpireSnapshotsConfig.retainLast()(Integer) toretainLast(int); unboxing threwNullPointerExceptionatExpireSnapshots.java:119.retain-lasthas no default —RETAIN_LAST_OPTIONis.intType().noDefaultValue()and no table property backs it.TestExpireSnapshotsConfigalready asserts it is null by default.IcebergSink.java:813callsconfig()unconditionally onceflink-maintenance.expire-snapshots.enabledis on.numSnapshots(already a nullableInteger) unset otherwise. Same shape as the siblingConvertEqualityDeletes.Builder.config()(ConvertEqualityDeletes.java:136-144), which guards its nullablescheduleOnIntervalSecond().Optional.ofNullable(...).orElse(null), used above formaxSnapshotAge, cannot work here:retainLasttakes a primitive, soorElse(null)unboxes and throws anyway.retain-lastis set is identical.Testing done
TestExpireSnapshotsConfig#configureBuilderWithoutRetainLast, feeding a default config intoExpireSnapshots.builder().config(...). Fails with the NPE above without the fix, passes with it.:iceberg-flink:iceberg-flink-2.1:testoverTestExpireSnapshotsConfig,TestExpireSnapshots,TestConvertEqualityDeletesConfig— 10 tests, 0 failures.spotlessCheck,checkstyleMain,checkstyleTestpassed. Module-wide:checknot run to completion locally (many MiniClusters); left to CI.