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.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
close
(AutoCloseable closeable) Close aAutoCloseable
dealing with nulls and exceptions.static void
close
(ErrorHandler errorHandler, AutoCloseable closeable) Close aAutoCloseable
delegating exceptions to theErrorHandler
.static void
closeAll
(AutoCloseable... closeables) Close all provided closeables.static void
closeAll
(Collection<? extends AutoCloseable> closeables) Close all provided closeables.static void
closeAll
(ErrorHandler errorHandler, AutoCloseable... closeables) Close all closeables and delegate exceptions to theErrorHandler
.static void
closeAll
(ErrorHandler errorHandler, Collection<? extends AutoCloseable> closeables) Close all closeables and delegate exceptions to theErrorHandler
.static void
quietClose
(AutoCloseable closeable) Quietly close aAutoCloseable
dealing with nulls and exceptions.static void
quietCloseAll
(AutoCloseable... closeables) Close all closeables in closeables.static void
quietCloseAll
(Collection<? extends AutoCloseable> closeables) Close all closeables in closeables.
-
Constructor Details
-
CloseHelper
private CloseHelper()
-
-
Method Details
-
quietClose
Quietly close aAutoCloseable
dealing 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 aAutoCloseable
dealing 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 aAutoCloseable
delegating 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.
-