Package com.apple.foundationdb.util
Class CloseableUtils
java.lang.Object
com.apple.foundationdb.util.CloseableUtils
Utility methods to help interact with
AutoCloseable classes.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloseAll(AutoCloseable... closeables) A utility to close multipleAutoCloseableobjects, preserving all the caught exceptions.
-
Method Details
-
closeAll
A utility to close multipleAutoCloseableobjects, preserving all the caught exceptions. The method would attempt to close all closeables in order, even if some failed. Note thatCloseExceptionis used to wrap any exception thrown during the closing process. The reason for that is the compiler fails to compile aAutoCloseable.close()implementation that throws a genericException(due toInterruptedExceptionissue) - We therefore have to catch and wrap all exceptions.- Parameters:
closeables- the given sequence ofAutoCloseable- Throws:
CloseException- in case any exception was caught during the process. The first exception will be added as acause. In case more than one exception was caught, it will be added as Suppressed.
-