JingsongLi commented on code in PR #9474:
URL: https://github.com/apache/paimon/pull/9474#discussion_r3911889011


##########
paimon-common/src/main/java/org/apache/paimon/globalindex/btree/BTreeIndexWriter.java:
##########
@@ -92,10 +95,15 @@ public BTreeIndexWriter(
             throws IOException {
         this.fileName = 
indexFileWriter.newFileName(BTreeGlobalIndexerFactory.IDENTIFIER);
         this.out = indexFileWriter.newOutputStream(this.fileName);
-        this.keySerializer = keySerializer;
-        this.comparator = keySerializer.createComparator();
-        // todo: we may enable bf to accelerate equal and in predicate in the 
future
-        this.writer = new SstFileWriter(out, blockSize, null, 
compressionFactory);
+        try {
+            this.keySerializer = keySerializer;
+            this.comparator = keySerializer.createComparator();
+            // todo: we may enable bf to accelerate equal and in predicate in 
the future
+            this.writer = new SstFileWriter(out, blockSize, null, 
compressionFactory);
+        } catch (RuntimeException e) {

Review Comment:
   [P2] Close the stream when constructor setup throws an Error
   
   This constructor-cleanup guard still misses `Error`. In particular, `new 
SstFileWriter(...)` allocates its data and index block buffers after `out` has 
been opened, so an `OutOfMemoryError` leaves the constructor without returning 
an `AutoCloseable` object and strands the output stream. A task/runtime may 
catch that failure while keeping the JVM alive, just like the abandoned-build 
paths this PR addresses. Please catch and rethrow `RuntimeException | Error` 
(or use the usual `catch (Throwable)` constructor-cleanup pattern) so every 
post-open setup failure closes `out`.
   



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

Reply via email to