From 027b37ade963bda7cb20ba5bad69010e06287d4d Mon Sep 17 00:00:00 2001 From: "oleksandr.nitavskyi" Date: Wed, 22 Apr 2026 15:46:12 +0200 Subject: [PATCH] [iceberg] Fix NPE in IcebergRestMetadataCommitter when table has no snapshots currentSnapshot() can return null for tables that exist but have no snapshots yet. The log statement in commitMetadataImpl did not handle this case, causing a NullPointerException. --- .../paimon/iceberg/IcebergRestMetadataCommitter.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/paimon-iceberg/src/main/java/org/apache/paimon/iceberg/IcebergRestMetadataCommitter.java b/paimon-iceberg/src/main/java/org/apache/paimon/iceberg/IcebergRestMetadataCommitter.java index bb358512fe53..ca07dc880127 100644 --- a/paimon-iceberg/src/main/java/org/apache/paimon/iceberg/IcebergRestMetadataCommitter.java +++ b/paimon-iceberg/src/main/java/org/apache/paimon/iceberg/IcebergRestMetadataCommitter.java @@ -162,8 +162,12 @@ private void commitMetadataImpl( } else { LOG.info( "create updates without base metadata. currentSnapshotId for base metadata: {}, for new metadata:{}", - metadata.currentSnapshot().snapshotId(), - newMetadata.currentSnapshot().snapshotId()); + metadata.currentSnapshot() != null + ? metadata.currentSnapshot().snapshotId() + : "No snapshot", + newMetadata.currentSnapshot() != null + ? newMetadata.currentSnapshot().snapshotId() + : "No snapshot"); updatdeBuilder = updatesForIncorrectBase(newMetadata); } }