Class CloseableUtils

java.lang.Object
com.apple.foundationdb.util.CloseableUtils

public class CloseableUtils extends Object
Utility methods to help interact with AutoCloseable classes.
  • Method Details

    • closeAll

      @API(INTERNAL) public static void closeAll(AutoCloseable... closeables) throws CloseException
      A utility to close multiple AutoCloseable objects, preserving all the caught exceptions. The method would attempt to close all closeables in order, even if some failed. Note that CloseException is used to wrap any exception thrown during the closing process. The reason for that is the compiler fails to compile a AutoCloseable.close() implementation that throws a generic Exception (due to InterruptedException issue) - We therefore have to catch and wrap all exceptions.
      Parameters:
      closeables - the given sequence of AutoCloseable
      Throws:
      CloseException - in case any exception was caught during the process. The first exception will be added as a cause. In case more than one exception was caught, it will be added as Suppressed.