hudi-agent commented on code in PR #18776: URL: https://github.com/apache/hudi/pull/18776#discussion_r3267048829
########## hudi-client/hudi-client-common/src/main/java/org/apache/hudi/util/AutoClosableUtils.java: ########## @@ -0,0 +1,74 @@ +/* + * 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.hudi.util; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; + +/** + * Utility methods for closing {@link AutoCloseable} resources. + */ +public final class AutoClosableUtils { Review Comment: 🤖 nit: the class name `AutoClosableUtils` drops the 'e' from `AutoCloseable` (the Java interface it wraps). Could you rename it to `AutoCloseableUtils` to match the interface spelling? As-is, someone searching for "AutoCloseable" utils won't naturally land here. <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub> ########## hudi-common/src/main/java/org/apache/hudi/common/bootstrap/index/hfile/HFileBootstrapIndexWriter.java: ########## @@ -175,27 +176,67 @@ private void commit() { * Close Writer Handles. */ public void close() { + if (closed) { + return; + } + IOException failure = null; try { - if (!closed) { + if (indexByPartitionWriter != null) { indexByPartitionWriter.close(); + } + } catch (IOException ioe) { Review Comment: 🤖 Both this `catch (IOException ioe)` and the one at line 194 only handle `IOException`. If `indexByPartitionWriter.close()` throws a `RuntimeException`, we skip closing `indexByFileIdWriter`, never set `closed = true`, and the original failure passed to `closeAfterFailedBegin` is shadowed (since that method at line 238 also only catches `HoodieIOException`). Could you widen these to `Throwable` (or at least also catch `RuntimeException`) so the second writer is always attempted and the original failure isn't lost? <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub> -- 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]
