smaheshwar-pltr commented on code in PR #17984:
URL: https://github.com/apache/iceberg/pull/17984#discussion_r4025319122


##########
core/src/main/java/org/apache/iceberg/ManifestListWriter.java:
##########
@@ -94,14 +99,26 @@ public Long nextRowId() {
   }
 
   public ManifestListFile toManifestListFile() {
-    if (manifestListKeyMetadata != null && 
manifestListKeyMetadata.encryptionKey() != null) {
-      String manifestListKeyID =
-          standardEncryptionManager.addManifestListKeyMetadata(
-              manifestListKeyMetadata.copyWithLength(writer.length()));
-      return new BaseManifestListFile(outputFile.location(), 
manifestListKeyID);
-    } else {
-      return new BaseManifestListFile(outputFile.location(), null);
+    Preconditions.checkState(closed, "Cannot build ManifestListFile, writer is 
not closed");
+    if (manifestListFile == null) {
+      if (manifestListKeyMetadata != null && 
manifestListKeyMetadata.encryptionKey() != null) {
+        this.encryptionKeys =

Review Comment:
   Agree that it reads confusingly as is.
   
   But the problem with moving this inside `close()` is that 
try-with-resources, which is used with these writers, means that `close()` is 
invoked when writing fails. That would then mean that even on failure, we 
implicitly contact the KMS, register + add keys to the encryption manager etc. 
which I'm not sure is great either.
   
   Maybe we can move forward for now and consider cleaning up the 
implementation as a follow-up here?



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