From 1155deaeb26a8b95eed86bdee2e5845a5baee801 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 17 Apr 2013 08:10:01 +0000
Subject: [PATCH] Added a StaticUtils.sleep(long) utility method.
---
opends/src/server/org/opends/server/util/StaticUtils.java | 18 ++++++++++++++++++
opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java | 9 +--------
opends/src/server/org/opends/server/protocols/http/HTTPConnectionHandler.java | 16 +++-------------
3 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/opends/src/server/org/opends/server/protocols/http/HTTPConnectionHandler.java b/opends/src/server/org/opends/server/protocols/http/HTTPConnectionHandler.java
index 2da8f45..56a4b74 100644
--- a/opends/src/server/org/opends/server/protocols/http/HTTPConnectionHandler.java
+++ b/opends/src/server/org/opends/server/protocols/http/HTTPConnectionHandler.java
@@ -100,6 +100,7 @@
import org.opends.server.types.InitializationException;
import org.opends.server.types.ResultCode;
import org.opends.server.util.SelectableCertificateKeyManager;
+import org.opends.server.util.StaticUtils;
/**
* This class defines a connection handler that will be used for communicating
@@ -673,14 +674,14 @@
stopHttpServer();
}
- sleep(1000);
+ StaticUtils.sleep(1000);
continue;
}
if (isListening())
{
// If already listening, then sleep for a bit and check again.
- sleep(1000);
+ StaticUtils.sleep(1000);
continue;
}
@@ -863,17 +864,6 @@
logError(NOTE_CONNHANDLER_STOPPED_LISTENING.get(handlerName));
}
- private void sleep(int millis)
- {
- try
- {
- Thread.sleep(millis);
- }
- catch (InterruptedException wokenUp)
- {
- }
- }
-
/** {@inheritDoc} */
@Override
public void toString(StringBuilder buffer)
diff --git a/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java b/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
index 235402c..a98dad6 100644
--- a/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
+++ b/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
@@ -1008,14 +1008,7 @@
logError(NOTE_CONNHANDLER_STOPPED_LISTENING.get(handlerName));
}
- try
- {
- Thread.sleep(1000);
- }
- catch (InterruptedException wokenUp)
- {
- }
-
+ StaticUtils.sleep(1000);
continue;
}
diff --git a/opends/src/server/org/opends/server/util/StaticUtils.java b/opends/src/server/org/opends/server/util/StaticUtils.java
index 855fa3e..210a86e 100644
--- a/opends/src/server/org/opends/server/util/StaticUtils.java
+++ b/opends/src/server/org/opends/server/util/StaticUtils.java
@@ -4693,6 +4693,24 @@
}
/**
+ * Calls {@link Thread#sleep(long)}, surrounding it with the mandatory
+ * <code>try</code> / <code>catch(InterruptedException)</code> block.
+ *
+ * @param millis
+ * the length of time to sleep in milliseconds
+ */
+ public static void sleep(long millis)
+ {
+ try
+ {
+ Thread.sleep(millis);
+ }
+ catch (InterruptedException wokenUp)
+ {
+ }
+ }
+
+ /**
* Returns an {@link Iterable} returning the passed in {@link Iterator}. THis
* allows using methods returning Iterators with foreach statements.
* <p>
--
Gitblit v1.10.0