amogh-jahagirdar commented on code in PR #7770:
URL: https://github.com/apache/iceberg/pull/7770#discussion_r1920390740


##########
core/src/main/java/org/apache/iceberg/SnapshotProducer.java:
##########
@@ -257,8 +259,15 @@ public Snapshot apply() {
           .run(index -> manifestFiles[index] = 
manifestsWithMetadata.get(manifests.get(index)));
 
       writer.addAll(Arrays.asList(manifestFiles));
-    } catch (IOException e) {
-      throw new RuntimeIOException(e, "Failed to write manifest list file");
+
+    } finally {
+      if (writer != null) {
+        try {
+          writer.close(); // must close before getting file length
+        } catch (IOException e) {
+          throw new RuntimeIOException(e, "Failed to close manifest list file 
writer");

Review Comment:
   Did this part need to change? 



##########
core/src/main/java/org/apache/iceberg/SnapshotProducer.java:
##########
@@ -257,8 +259,15 @@ public Snapshot apply() {
           .run(index -> manifestFiles[index] = 
manifestsWithMetadata.get(manifests.get(index)));
 
       writer.addAll(Arrays.asList(manifestFiles));
-    } catch (IOException e) {
-      throw new RuntimeIOException(e, "Failed to write manifest list file");
+
+    } finally {
+      if (writer != null) {
+        try {
+          writer.close(); // must close before getting file length
+        } catch (IOException e) {
+          throw new RuntimeIOException(e, "Failed to close manifest list file 
writer");

Review Comment:
   Oh I see we need to explicitly flush so that by the time 
"toManifestListFile" is called we are guaranteed to have a length to work with 



##########
core/src/test/java/org/apache/iceberg/TestManifestEncryption.java:
##########
@@ -85,7 +85,7 @@ public class TestManifestEncryption {
 
   private static final DataFile DATA_FILE =
       new GenericDataFile(
-          0,
+          SPEC.specId(),

Review Comment:
   Resolving this



##########
core/src/main/java/org/apache/iceberg/encryption/StandardEncryptionManager.java:
##########
@@ -81,22 +136,75 @@ private SecureRandom workerRNG() {
     return lazyRNG;
   }
 
+  /**
+   * @deprecated will be removed in 1.8.0; use {@link #currentSnapshotKeyId()} 
instead.

Review Comment:
   same as below



##########
core/src/main/java/org/apache/iceberg/encryption/StandardEncryptionManager.java:
##########
@@ -81,22 +136,75 @@ private SecureRandom workerRNG() {
     return lazyRNG;
   }
 
+  /**
+   * @deprecated will be removed in 1.8.0; use {@link #currentSnapshotKeyId()} 
instead.
+   */
+  @Deprecated
   public ByteBuffer wrapKey(ByteBuffer secretKey) {
-    if (kmsClient == null) {
+    if (transientState == null) {
       throw new IllegalStateException(
           "Cannot wrap key after called after serialization (missing KMS 
client)");
     }
 
-    return kmsClient.wrapKey(secretKey, tableKeyId);
+    return transientState.kmsClient.wrapKey(secretKey, tableKeyId);
   }
 
+  /**
+   * @deprecated will be removed in 1.8.0; use {@link #unwrapKey(String)}} 
instead.
+   */

Review Comment:
   Note, if this PR doesn't have any more comments and we think we can get it 
in for 1.8 we should update this to be "will be removed in 1.9.0"



##########
core/src/main/java/org/apache/iceberg/BaseManifestListFile.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg;
+
+import java.io.Serializable;
+import java.nio.ByteBuffer;
+import org.apache.iceberg.encryption.EncryptionManager;
+import org.apache.iceberg.encryption.EncryptionUtil;
+import org.apache.iceberg.util.ByteBuffers;
+
+class BaseManifestListFile implements ManifestListFile, Serializable {
+  private final String location;
+  private final long snapshotId;
+  private final String keyMetadataKeyID;
+  // stored as a byte array to be Serializable
+  private final byte[] encryptedKeyMetadata;
+
+  BaseManifestListFile(
+      String location, long snapshotId, String keyMetadataKeyID, ByteBuffer 
encryptedKeyMetadata) {
+    this.location = location;
+    this.snapshotId = snapshotId;
+    this.encryptedKeyMetadata = ByteBuffers.toByteArray(encryptedKeyMetadata);
+    this.keyMetadataKeyID = keyMetadataKeyID;
+  }
+
+  @Override
+  public String location() {
+    return location;
+  }
+
+  @Override
+  public long snapshotId() {
+    return snapshotId;
+  }
+
+  @Override
+  public String keyMetadataKeyId() {
+    return keyMetadataKeyID;
+  }
+
+  @Override
+  public ByteBuffer encryptedKeyMetadata() {
+    if (encryptedKeyMetadata == null) {
+      return null;
+    }
+
+    return ByteBuffer.wrap(encryptedKeyMetadata);
+  }
+
+  @Override
+  public ByteBuffer decryptKeyMetadata(EncryptionManager em) {

Review Comment:
   Yeah I'm not sure if there's an alternative to passing the EncryptionManager 
at least with the current design of EncryptingFileIO



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