ahmedabu98 commented on code in PR #37782:
URL: https://github.com/apache/beam/pull/37782#discussion_r2896038862
##########
sdks/java/io/iceberg/src/test/java/org/apache/beam/sdk/io/iceberg/RecordWriterManagerTest.java:
##########
@@ -980,7 +981,86 @@ public void testRecordWriterKeepsFileIOOpenUntilClose()
throws IOException {
writer.write(IcebergUtils.beamRowToIcebergRecord(ICEBERG_SCHEMA, row));
writer.close();
- assertTrue("FileIO should be closed after writer close",
trackingFileIO.closed);
+ // RecordWriter must NOT close FileIO — it's the catalog's shared instance.
+ assertFalse("RecordWriter.close() must not close the shared FileIO",
trackingFileIO.closed);
+ }
+
+ /**
+ * Verifies that when multiple writers share the same FileIO, closing any
writer does not close
+ * the shared FileIO — that is the responsibility of
RecordWriterManager.close().
+ */
+ @Test
+ public void testMultipleWritersSharingFileIOSurviveBatchClose() throws
IOException {
+ // Create two tables that share the same FileIO (simulating dynamic
destinations
+ // backed by the same catalog)
+ TableIdentifier tableId1 =
+ TableIdentifier.of(
+ "default",
+ "table_batch_close_a_" + UUID.randomUUID().toString().replace("-",
"").substring(0, 6));
+ TableIdentifier tableId2 =
+ TableIdentifier.of(
+ "default",
+ "table_batch_close_b_" + UUID.randomUUID().toString().replace("-",
"").substring(0, 6));
+ Table table1 = warehouse.createTable(tableId1, ICEBERG_SCHEMA);
+ Table table2 = warehouse.createTable(tableId2, ICEBERG_SCHEMA);
+
+ // Both tables share the same CloseTrackingFileIO — mirrors how a catalog
returns
+ // the same shared FileIO instance for all tables
Review Comment:
Actually I think each table has its own FileIO instance
--
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]