xloya commented on a change in pull request #3977:
URL: https://github.com/apache/iceberg/pull/3977#discussion_r801209738



##########
File path: core/src/main/java/org/apache/iceberg/io/PartitionedFanoutWriter.java
##########
@@ -60,11 +93,18 @@ public void write(T row) throws IOException {
 
   @Override
   public void close() throws IOException {
-    if (!writers.isEmpty()) {
-      for (PartitionKey key : writers.keySet()) {
-        writers.get(key).close();
+    ConcurrentMap<PartitionKey, RollingFileWriter> writersMap = 
writers.asMap();
+    if (writersMap.size() > 0) {
+      // close all remaining rolling file writers
+      try {
+        Tasks.foreach(writersMap.values())
+            .throwFailureWhenFinished()
+            .noRetry()
+            .run(RollingFileWriter::close, IOException.class);
+      } catch (IOException e) {
+        throw new UncheckedIOException("Failed to close rolling file writer", 
e);
       }
-      writers.clear();
     }
+    writers.invalidateAll();

Review comment:
       In fact, this is mainly to clear the references in the Map, and I think 
it has no effect on the second closing of the Writer, because the 
`BaseTaskWriter` will judge whether the writer is `null`. After the first 
close, the writer has been set to `null`




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