Package org.forgerock.util
Class Closeables
- java.lang.Object
-
- org.forgerock.util.Closeables
-
public final class Closeables extends Object
Common utility methods for Closeables.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
closeSilently(Closeable... resources)
Closes the provided resources ignoring any errors which occurred.static void
closeSilently(Iterable<? extends Closeable> 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.
-
-
-
Method Detail
-
closeSilently
public static void closeSilently(Closeable... resources)
Closes the provided resources ignoring any errors which occurred.- Parameters:
resources
- The resources to be closed, which may benull
.
-
closeSilently
public static void closeSilently(Iterable<? extends Closeable> resources)
Closes the provided resources ignoring any errors which occurred.- Parameters:
resources
- The resources to be closed, which may benull
.
-
closeSilentlyAsync
public static Runnable closeSilentlyAsync(Closeable... resources)
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
-
-