Package org.forgerock.util
Class Closeables
java.lang.Object
org.forgerock.util.Closeables
Common utility methods for Closeables.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
closeSilently
(Closeable... resources) Closes the provided resources ignoring any errors which occurred.static void
closeSilently
(AutoCloseable... resources) Closes the provided resources ignoring any errors which occurred.static void
closeSilently
(Iterable<? extends AutoCloseable> resources) Closes the provided resources ignoring any errors which occurred.static Runnable
closeSilentlyAsync
(Closeable... resources) Closes asynchronously the provided resources ignoring any errors which occurred.static Runnable
closeSilentlyAsync
(AutoCloseable... resources) Closes asynchronously the provided resources ignoring any errors which occurred.
-
Method Details
-
closeSilently
Closes the provided resources ignoring any errors which occurred.- Parameters:
resources
- The resources to be closed, which may benull
.
-
closeSilently
Closes the provided resources ignoring any errors which occurred.- Parameters:
resources
- The resources to be closed, which may benull
.
-
closeSilently
Closes the provided resources ignoring any errors which occurred.- Parameters:
resources
- The resources to be closed, which may benull
.
-
closeSilentlyAsync
Closes asynchronously the provided resources ignoring any errors which occurred.Meant to be used with
Promise.thenAlways(Runnable)
orPromise.thenFinally(Runnable)
:Usage example with HTTP Framework:
Request request = new Request(); Promise<Response, NeverThrowsException> promise = handler.handle(context, request) .thenAlways(closeSilentlyAsync(request));
- Parameters:
resources
- The resources to be closed, which may benull
.- Returns:
- Runnable to be used as callback
-
closeSilentlyAsync
Closes asynchronously the provided resources ignoring any errors which occurred.Meant to be used with
Promise.thenAlways(Runnable)
orPromise.thenFinally(Runnable)
:Usage example with HTTP Framework:
Request request = new Request(); Promise<Response, NeverThrowsException> promise = handler.handle(context, request) .thenAlways(closeSilentlyAsync(request));
- Parameters:
resources
- The resources to be closed, which may benull
.- Returns:
- Runnable to be used as callback
-