yyanyy commented on a change in pull request #2878:
URL: https://github.com/apache/iceberg/pull/2878#discussion_r678536728
##########
File path: api/src/main/java/org/apache/iceberg/io/CloseableGroup.java
##########
@@ -23,20 +23,47 @@
import java.io.IOException;
import java.util.Deque;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public abstract class CloseableGroup implements Closeable {
- private final Deque<Closeable> closeables = Lists.newLinkedList();
+ private static final Logger LOG =
LoggerFactory.getLogger(CloseableGroup.class);
- protected void addCloseable(Closeable closeable) {
+ private final Deque<AutoCloseable> closeables = Lists.newLinkedList();
+ private boolean suppressCloseFailure = false;
+
+ protected void addCloseable(AutoCloseable closeable) {
closeables.add(closeable);
}
+ protected void setSuppressCloseFailure(boolean shouldSuppress) {
+ this.suppressCloseFailure = shouldSuppress;
+ }
+
@Override
public void close() throws IOException {
Review comment:
Per API contract of `Closeable` and `AutoCloseable`, `AutoCloseable`'s
close does not require to be idempotent, but `Closeable` would be. Since we are
modifying this class to also accept `AutoCloseable` too, if the class extending
it registers an `AutoCloseable` resource then it may not be idempotent. I
personally think this would be low risk since `close()` call is something the
caller can control, and usually I don't think there's a use case where the
`close` would be explicitly called twice, and even so and problem occurs, if
the caller is not interested they can suppress the exceptions. Are you aware of
any such use case that would have issue with this?
--
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]