From 2059011fb5551e64dd8cc9985f7182ca323188c2 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 26 Jun 2013 09:04:35 +0000
Subject: [PATCH] StaticUtils.java: Added closeSilently(Iterable<? extends Closeable>)
---
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/StaticUtils.java | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/StaticUtils.java b/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/StaticUtils.java
index f89e2b0..bbfd09e 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/StaticUtils.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/StaticUtils.java
@@ -81,10 +81,10 @@
*/
public static final byte[] EMPTY_BYTES = new byte[0];
- // The name of the time zone for universal coordinated time (UTC).
+ /** The name of the time zone for universal coordinated time (UTC). */
private static final String TIME_ZONE_UTC = "UTC";
- // UTC TimeZone is assumed to never change over JVM lifetime
+ /** UTC TimeZone is assumed to never change over JVM lifetime. */
private static final TimeZone TIME_ZONE_UTC_OBJ = TimeZone.getTimeZone(TIME_ZONE_UTC);
/**
@@ -1174,6 +1174,22 @@
* The resources to be closed, which may be {@code null}.
*/
public static void closeSilently(Closeable... resources) {
+ if (resources == null) {
+ return;
+ }
+ closeSilently(Arrays.asList(resources));
+ }
+
+ /**
+ * Closes the provided resources ignoring any errors which occurred.
+ *
+ * @param resources
+ * The resources to be closed, which may be {@code null}.
+ */
+ public static void closeSilently(Iterable<? extends Closeable> resources) {
+ if (resources == null) {
+ return;
+ }
for (Closeable r : resources) {
try {
if (r != null) {
--
Gitblit v1.10.0