Package org.agrona
Class CloseHelper
- java.lang.Object
-
- org.agrona.CloseHelper
-
public final class CloseHelper extends java.lang.Object
Utility functions to help with usingAutoCloseable
resources. If a null exception is passed then it is ignored.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
CloseHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
close(java.lang.AutoCloseable closeable)
Close aAutoCloseable
dealing with nulls and exceptions.static void
close(ErrorHandler errorHandler, java.lang.AutoCloseable closeable)
Close aAutoCloseable
delegating exceptions to theErrorHandler
.static void
closeAll(java.lang.AutoCloseable... closeables)
Close all provided closeables.static void
closeAll(java.util.Collection<? extends java.lang.AutoCloseable> closeables)
Close all provided closeables.static void
closeAll(ErrorHandler errorHandler, java.lang.AutoCloseable... closeables)
Close all closeables and delegate exceptions to theErrorHandler
.static void
closeAll(ErrorHandler errorHandler, java.util.Collection<? extends java.lang.AutoCloseable> closeables)
Close all closeables and delegate exceptions to theErrorHandler
.static void
quietClose(java.lang.AutoCloseable closeable)
Quietly close aAutoCloseable
dealing with nulls and exceptions.static void
quietCloseAll(java.lang.AutoCloseable... closeables)
Close all closeables in closeables.static void
quietCloseAll(java.util.Collection<? extends java.lang.AutoCloseable> closeables)
Close all closeables in closeables.
-
-
-
Method Detail
-
quietClose
public static void quietClose(java.lang.AutoCloseable closeable)
Quietly close aAutoCloseable
dealing with nulls and exceptions.- Parameters:
closeable
- to be closed.
-
quietCloseAll
public static void quietCloseAll(java.util.Collection<? extends java.lang.AutoCloseable> closeables)
Close all closeables in closeables. All exceptions and nulls will be ignored.- Parameters:
closeables
- to be closed.
-
quietCloseAll
public static void quietCloseAll(java.lang.AutoCloseable... closeables)
Close all closeables in closeables. All exceptions and nulls will be ignored.- Parameters:
closeables
- to be closed.
-
close
public static void close(java.lang.AutoCloseable closeable)
Close aAutoCloseable
dealing with nulls and exceptions. This version re-throws exceptions as runtime exceptions.- Parameters:
closeable
- to be closed.
-
closeAll
public static void closeAll(java.util.Collection<? extends java.lang.AutoCloseable> closeables)
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
public static void closeAll(java.lang.AutoCloseable... closeables)
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
public static void close(ErrorHandler errorHandler, java.lang.AutoCloseable closeable)
Close aAutoCloseable
delegating exceptions to theErrorHandler
.- Parameters:
errorHandler
- to delegate exceptions to.closeable
- to be closed.
-
closeAll
public static void closeAll(ErrorHandler errorHandler, java.util.Collection<? extends java.lang.AutoCloseable> closeables)
Close all closeables and delegate exceptions to theErrorHandler
.- Parameters:
errorHandler
- to delegate exceptions to.closeables
- to be closed.
-
closeAll
public static void closeAll(ErrorHandler errorHandler, java.lang.AutoCloseable... closeables)
Close all closeables and delegate exceptions to theErrorHandler
.- Parameters:
errorHandler
- to delegate exceptions to.closeables
- to be closed.
-
-