Package org.agrona
Class CloseHelper
java.lang.Object
org.agrona.CloseHelper
Utility functions to help with using
AutoCloseable resources. If a null exception is passed
then it is ignored.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclose(AutoCloseable closeable) Close aAutoCloseabledealing with nulls and exceptions.static voidclose(ErrorHandler errorHandler, AutoCloseable closeable) Close aAutoCloseabledelegating exceptions to theErrorHandler.static voidcloseAll(AutoCloseable... closeables) Close all provided closeables.static voidcloseAll(Collection<? extends AutoCloseable> closeables) Close all provided closeables.static voidcloseAll(ErrorHandler errorHandler, AutoCloseable... closeables) Close all closeables and delegate exceptions to theErrorHandler.static voidcloseAll(ErrorHandler errorHandler, Collection<? extends AutoCloseable> closeables) Close all closeables and delegate exceptions to theErrorHandler.static voidquietClose(AutoCloseable closeable) Quietly close aAutoCloseabledealing with nulls and exceptions.static voidquietCloseAll(AutoCloseable... closeables) Close all closeables in closeables.static voidquietCloseAll(Collection<? extends AutoCloseable> closeables) Close all closeables in closeables.
-
Method Details
-
quietClose
Quietly close aAutoCloseabledealing with nulls and exceptions.- Parameters:
closeable- to be closed.
-
quietCloseAll
Close all closeables in closeables. All exceptions and nulls will be ignored.- Parameters:
closeables- to be closed.
-
quietCloseAll
Close all closeables in closeables. All exceptions and nulls will be ignored.- Parameters:
closeables- to be closed.
-
close
Close aAutoCloseabledealing with nulls and exceptions. This version re-throws exceptions as runtime exceptions.- Parameters:
closeable- to be closed.
-
closeAll
Close all provided closeables. If any of them throw then throw that exception. If multiple closeables throw an exception when being closed, then throw an exception that contains all of them as suppressed exceptions.- Parameters:
closeables- to be closed.
-
closeAll
Close all provided closeables. If any of them throw then throw that exception. If multiple closeables throw an exception when being closed, then throw an exception that contains all of them as suppressed exceptions.- Parameters:
closeables- to be closed.
-
close
Close aAutoCloseabledelegating exceptions to theErrorHandler.- Parameters:
errorHandler- to delegate exceptions to.closeable- to be closed.
-
closeAll
public static void closeAll(ErrorHandler errorHandler, Collection<? extends AutoCloseable> closeables) Close all closeables and delegate exceptions to theErrorHandler.- Parameters:
errorHandler- to delegate exceptions to.closeables- to be closed.
-
closeAll
Close all closeables and delegate exceptions to theErrorHandler.- Parameters:
errorHandler- to delegate exceptions to.closeables- to be closed.
-