java.lang.Object
org.apache.arrow.util.AutoCloseables
Utilities for AutoCloseable classes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA closeable wrapper that will close the underlying closeables if a commit does not occur. -
Method Summary
Modifier and TypeMethodDescriptionstatic AutoCloseableall(@Nullable Collection<? extends @Nullable AutoCloseable> autoCloseables) static voidclose(@Nullable AutoCloseable... autoCloseables) Closes all autoCloseables if not null and suppresses subsequent exceptions if more than one.static voidclose(@Nullable Iterable<? extends @Nullable AutoCloseable> ac) Closes all autoCloseables if not null and suppresses subsequent exceptions if more than one.static voidclose(@Nullable Iterable<? extends @Nullable AutoCloseable>... closeables) Callsclose(Iterable)on the flattened list of closeables.static voidclose(Throwable t, @Nullable AutoCloseable... autoCloseables) Closes all autoCloseables if not null and suppresses exceptions by adding them to t.static voidclose(Throwable t, @Nullable Iterable<? extends @Nullable AutoCloseable> autoCloseables) Closes all autoCloseables if not null and suppresses exceptions by adding them to t.static voidcloseNoChecked(@Nullable AutoCloseable autoCloseable) close() anAutoCloseablewithout throwing a (checked)Exception.static Iterable<AutoCloseable>iter(@Nullable AutoCloseable... ac) Convertsacto aIterablefiltering out any null values.static AutoCloseablenoop()Get an AutoCloseable that does nothing.rollbackable(@Nullable AutoCloseable... closeables) Creates anAutoCloseables.RollbackCloseablefrom the given closeables.
-
Method Details
-
all
public static AutoCloseable all(@Nullable Collection<? extends @Nullable AutoCloseable> autoCloseables) -
close
Closes all autoCloseables if not null and suppresses exceptions by adding them to t.- Parameters:
t- the throwable to add suppressed exception toautoCloseables- the closeables to close
-
close
public static void close(Throwable t, @Nullable Iterable<? extends @Nullable AutoCloseable> autoCloseables) Closes all autoCloseables if not null and suppresses exceptions by adding them to t.- Parameters:
t- the throwable to add suppressed exception toautoCloseables- the closeables to close
-
close
Closes all autoCloseables if not null and suppresses subsequent exceptions if more than one.- Parameters:
autoCloseables- the closeables to close- Throws:
Exception
-
close
Closes all autoCloseables if not null and suppresses subsequent exceptions if more than one.- Parameters:
ac- the closeables to close- Throws:
Exception
-
close
@SafeVarargs public static void close(@Nullable Iterable<? extends @Nullable AutoCloseable>... closeables) throws Exception Callsclose(Iterable)on the flattened list of closeables.- Throws:
Exception
-
iter
Convertsacto aIterablefiltering out any null values. -
rollbackable
Creates anAutoCloseables.RollbackCloseablefrom the given closeables. -
closeNoChecked
close() anAutoCloseablewithout throwing a (checked)Exception. This wraps the close() call with a try-catch that will rethrow an Exception wrapped with aRuntimeException, providing a way to call close() without having to do the try-catch everywhere or propagate the Exception.- Parameters:
autoCloseable- the AutoCloseable to close; may be null- Throws:
RuntimeException- if an Exception occurs; the Exception is wrapped by the RuntimeException
-
noop
Get an AutoCloseable that does nothing.- Returns:
- A do-nothing autocloseable
-