From 6781e3b79f4ff822aeb68d4d3a3dcd8b49ad86f9 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Wed, 12 Sep 2007 00:03:02 +0000
Subject: [PATCH] Make a couple of changes to help improve server performance:
---
opendj-sdk/opends/src/server/org/opends/server/schema/UTCTimeSyntax.java | 50
opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeOrderingMatchingRule.java | 53 -
opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedMD5PasswordStorageScheme.java | 173 +--
opendj-sdk/opends/src/server/org/opends/server/extensions/DigestMD5SASLMechanismHandler.java | 45
opendj-sdk/opends/src/server/org/opends/server/extensions/TraditionalWorkQueue.java | 255 ++--
opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java | 509 +---------
opendj-sdk/opends/src/server/org/opends/server/extensions/RandomPasswordGenerator.java | 34
opendj-sdk/opends/src/server/org/opends/server/loggers/AsyncronousTextWriter.java | 51
opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA256PasswordStorageScheme.java | 173 +--
opendj-sdk/opends/src/server/org/opends/server/config/ConfigEntry.java | 101 -
opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA384PasswordStorageScheme.java | 173 +--
opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeEqualityMatchingRule.java | 46
opendj-sdk/opends/src/server/org/opends/server/core/LockFileManager.java | 31
opendj-sdk/opends/src/server/org/opends/server/extensions/SHA1PasswordStorageScheme.java | 92 -
opendj-sdk/opends/src/server/org/opends/server/extensions/CRAMMD5SASLMechanismHandler.java | 22
opendj-sdk/opends/src/server/org/opends/server/extensions/CryptPasswordStorageScheme.java | 10
opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA512PasswordStorageScheme.java | 173 +--
opendj-sdk/opends/src/server/org/opends/server/util/Crypt.java | 11
opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA1PasswordStorageScheme.java | 173 +--
opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeSyntax.java | 51
opendj-sdk/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java | 30
opendj-sdk/opends/src/server/org/opends/server/extensions/MD5PasswordStorageScheme.java | 92 -
opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java | 376 +++----
23 files changed, 969 insertions(+), 1,755 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/config/ConfigEntry.java b/opendj-sdk/opends/src/server/org/opends/server/config/ConfigEntry.java
index cdf8d8e..56930d9 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/config/ConfigEntry.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/config/ConfigEntry.java
@@ -25,7 +25,6 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
package org.opends.server.config;
-import org.opends.messages.Message;
@@ -34,12 +33,13 @@
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.locks.ReentrantLock;
+import org.opends.messages.Message;
import org.opends.server.api.ConfigAddListener;
import org.opends.server.api.ConfigChangeListener;
import org.opends.server.api.ConfigDeleteListener;
import org.opends.server.core.DirectoryServer;
+import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
@@ -47,10 +47,9 @@
import org.opends.server.types.ObjectClass;
import org.opends.server.types.DebugLogLevel;
+import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
-import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.util.StaticUtils.*;
@@ -94,7 +93,7 @@
private Entry entry;
// The lock used to provide threadsafe access to this configuration entry.
- private ReentrantLock entryLock;
+ private Object entryLock;
@@ -115,7 +114,7 @@
addListeners = new CopyOnWriteArrayList<ConfigAddListener>();
changeListeners = new CopyOnWriteArrayList<ConfigChangeListener>();
deleteListeners = new CopyOnWriteArrayList<ConfigDeleteListener>();
- entryLock = new ReentrantLock();
+ entryLock = new Object();
}
@@ -144,16 +143,10 @@
*/
public void setEntry(Entry entry)
{
- entryLock.lock();
-
- try
+ synchronized (entryLock)
{
this.entry = entry;
}
- finally
- {
- entryLock.unlock();
- }
}
@@ -358,25 +351,10 @@
{
ConfigEntry conflictingChild;
- entryLock.lock();
-
- try
+ synchronized (entryLock)
{
conflictingChild = children.putIfAbsent(childEntry.getDN(), childEntry);
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
-
- conflictingChild = null;
- }
- finally
- {
- entryLock.unlock();
- }
if (conflictingChild != null)
{
@@ -405,47 +383,44 @@
public ConfigEntry removeChild(DN childDN)
throws ConfigException
{
- entryLock.lock();
-
- try
+ synchronized (entryLock)
{
- ConfigEntry childEntry = children.get(childDN);
- if (childEntry == null)
+ try
{
- Message message = ERR_CONFIG_ENTRY_NO_SUCH_CHILD.get(
- childDN.toString(), entry.getDN().toString());
- throw new ConfigException(message);
- }
+ ConfigEntry childEntry = children.get(childDN);
+ if (childEntry == null)
+ {
+ Message message = ERR_CONFIG_ENTRY_NO_SUCH_CHILD.get(
+ childDN.toString(), entry.getDN().toString());
+ throw new ConfigException(message);
+ }
- if (childEntry.hasChildren())
+ if (childEntry.hasChildren())
+ {
+ Message message = ERR_CONFIG_ENTRY_CANNOT_REMOVE_NONLEAF.get(
+ childDN.toString(), entry.getDN().toString());
+ throw new ConfigException(message);
+ }
+
+ children.remove(childDN);
+ return childEntry;
+ }
+ catch (ConfigException ce)
{
- Message message = ERR_CONFIG_ENTRY_CANNOT_REMOVE_NONLEAF.get(
- childDN.toString(), entry.getDN().toString());
- throw new ConfigException(message);
+ throw ce;
}
-
- children.remove(childDN);
- return childEntry;
- }
- catch (ConfigException ce)
- {
- throw ce;
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ catch (Exception e)
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
- Message message = ERR_CONFIG_ENTRY_CANNOT_REMOVE_CHILD.
- get(String.valueOf(childDN), String.valueOf(entry.getDN()),
- stackTraceToSingleLineString(e));
- throw new ConfigException(message, e);
- }
- finally
- {
- entryLock.unlock();
+ Message message = ERR_CONFIG_ENTRY_CANNOT_REMOVE_CHILD.
+ get(String.valueOf(childDN), String.valueOf(entry.getDN()),
+ stackTraceToSingleLineString(e));
+ throw new ConfigException(message, e);
+ }
}
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/core/LockFileManager.java b/opendj-sdk/opends/src/server/org/opends/server/core/LockFileManager.java
index da15e4a..87367e9 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/core/LockFileManager.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/core/LockFileManager.java
@@ -33,14 +33,13 @@
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.util.HashMap;
-import java.util.concurrent.locks.ReentrantLock;
import org.opends.server.api.Backend;
-
-import static org.opends.server.loggers.debug.DebugLogger.*;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.DebugLogLevel;
+
import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -74,7 +73,7 @@
new HashMap<String,Integer>();
// The lock providing threadsafe access to the lock map data.
- private static ReentrantLock mapLock = new ReentrantLock();
+ private static Object mapLock = new Object();
@@ -91,9 +90,7 @@
public static boolean acquireSharedLock(String lockFile,
StringBuilder failureReason)
{
- mapLock.lock();
-
- try
+ synchronized (mapLock)
{
// Check to see if there's already an exclusive lock on the file. If so,
// then we can't get a shared lock on it.
@@ -249,10 +246,6 @@
return true;
}
}
- finally
- {
- mapLock.unlock();
- }
}
@@ -270,9 +263,7 @@
public static boolean acquireExclusiveLock(String lockFile,
StringBuilder failureReason)
{
- mapLock.lock();
-
- try
+ synchronized (mapLock)
{
// Check to see if there's already an exclusive lock on the file. If so,
// then we can't get another exclusive lock on it.
@@ -424,10 +415,6 @@
return true;
}
}
- finally
- {
- mapLock.unlock();
- }
}
@@ -451,9 +438,7 @@
public static boolean releaseLock(String lockFile,
StringBuilder failureReason)
{
- mapLock.lock();
-
- try
+ synchronized (mapLock)
{
// See if we hold an exclusive lock on the file. If so, then release it
// and get remove it from the lock table.
@@ -554,10 +539,6 @@
failureReason.append(ERR_FILELOCKER_UNLOCK_UNKNOWN_FILE.get(lockFile));
return false;
}
- finally
- {
- mapLock.unlock();
- }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/CRAMMD5SASLMechanismHandler.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/CRAMMD5SASLMechanismHandler.java
index 7ead7ab..cc0e904 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/CRAMMD5SASLMechanismHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/CRAMMD5SASLMechanismHandler.java
@@ -25,7 +25,6 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
package org.opends.server.extensions;
-import org.opends.messages.Message;
@@ -36,8 +35,8 @@
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
+import org.opends.messages.Message;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.CramMD5SASLMechanismHandlerCfg;
import org.opends.server.admin.std.server.SASLMechanismHandlerCfg;
@@ -48,10 +47,12 @@
import org.opends.server.core.BindOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.PasswordPolicyState;
+import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.types.AuthenticationInfo;
import org.opends.server.types.ByteString;
import org.opends.server.types.ConfigChangeResult;
+import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -59,11 +60,8 @@
import org.opends.server.types.LockManager;
import org.opends.server.types.ResultCode;
-import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
-import org.opends.server.types.DebugLogLevel;
import static org.opends.messages.ExtensionMessages.*;
-
+import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -112,7 +110,7 @@
// The lock that will be used to provide threadsafe access to the message
// digest.
- private ReentrantLock digestLock;
+ private Object digestLock;
// The random number generator that we will use to create the server
// challenge.
@@ -147,7 +145,7 @@
// Initialize the variables needed for the MD5 digest creation.
- digestLock = new ReentrantLock();
+ digestLock = new Object();
randomGenerator = new SecureRandom();
try
@@ -536,9 +534,7 @@
// Grab a lock to protect the MD5 digest generation.
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
// If the password is longer than the HMAC-MD5 block length, then use an
// MD5 digest of the password rather than the password itself.
@@ -575,10 +571,6 @@
// Return an MD5 digest of the resulting array.
return md5Digest.digest(oPadAndHash);
}
- finally
- {
- digestLock.unlock();
- }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
index 3021309..53f47d4 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
@@ -53,7 +53,6 @@
import java.util.zip.ZipOutputStream;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.locks.ReentrantLock;
import javax.crypto.Mac;
import org.opends.messages.Message;
@@ -155,7 +154,7 @@
// The write lock used to ensure that only one thread can apply a
// configuration update at any given time.
- private ReentrantLock configLock;
+ private Object configLock;
// The path to the configuration file.
private String configFile;
@@ -196,7 +195,7 @@
throws InitializationException
{
// Initialize the config lock.
- configLock = new ReentrantLock();
+ configLock = new Object();
// Determine whether we should try to start using the last known good
@@ -1276,9 +1275,7 @@
// Grab the config lock to ensure that only one config update may be in
// progress at any given time.
- configLock.lock();
-
- try
+ synchronized (configLock)
{
// Make sure that the target DN does not already exist. If it does, then
// fail.
@@ -1414,10 +1411,6 @@
throw new DirectoryException(resultCode, message);
}
}
- finally
- {
- configLock.unlock();
- }
}
@@ -1456,9 +1449,7 @@
// Grab the config lock to ensure that only one config update may be in
// progress at any given time.
- configLock.lock();
-
- try
+ synchronized (configLock)
{
// Get the target entry. If it does not exist, then fail.
ConfigEntry entry = configEntries.get(entryDN);
@@ -1590,10 +1581,6 @@
throw new DirectoryException(resultCode, message);
}
}
- finally
- {
- configLock.unlock();
- }
}
@@ -1656,10 +1643,7 @@
// Grab the config lock to ensure that only one config update may be in
// progress at any given time.
- configLock.lock();
-
-
- try
+ synchronized (configLock)
{
// Get the DN of the target entry for future reference.
DN entryDN = e.getDN();
@@ -1773,10 +1757,6 @@
throw new DirectoryException(resultCode, message);
}
}
- finally
- {
- configLock.unlock();
- }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/CryptPasswordStorageScheme.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/CryptPasswordStorageScheme.java
index c4095ec..1f0e144 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/CryptPasswordStorageScheme.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/CryptPasswordStorageScheme.java
@@ -30,7 +30,6 @@
import java.util.Arrays;
import java.util.Random;
-import java.util.concurrent.locks.ReentrantLock;
import org.opends.messages.Message;
import org.opends.server.admin.std.server.CryptPasswordStorageSchemeCfg;
@@ -76,7 +75,7 @@
+"ABCDEFGHIJKLMNOPQRSTUVWXYZ").getBytes();
private final Random randomSaltIndex = new Random();
- private final ReentrantLock saltLock = new ReentrantLock();
+ private final Object saltLock = new Object();
private final Crypt crypt = new Crypt();
@@ -144,9 +143,8 @@
* @return a random 2-byte salt
*/
private byte[] randomSalt() {
- saltLock.lock();
-
- try {
+ synchronized (saltLock)
+ {
byte[] salt = new byte[2];
int sb1 = randomSaltIndex.nextInt(SALT_CHARS.length);
int sb2 = randomSaltIndex.nextInt(SALT_CHARS.length);
@@ -154,8 +152,6 @@
salt[1] = SALT_CHARS[sb2];
return salt;
- } finally {
- saltLock.unlock();
}
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/DigestMD5SASLMechanismHandler.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/DigestMD5SASLMechanismHandler.java
index bb42dab..f31ad80 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/DigestMD5SASLMechanismHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/DigestMD5SASLMechanismHandler.java
@@ -25,7 +25,6 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
package org.opends.server.extensions;
-import org.opends.messages.Message;
@@ -39,8 +38,8 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
+import org.opends.messages.Message;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.DigestMD5SASLMechanismHandlerCfg;
import org.opends.server.admin.std.server.SASLMechanismHandlerCfg;
@@ -52,29 +51,26 @@
import org.opends.server.core.BindOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.PasswordPolicyState;
+import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.AuthenticationInfo;
import org.opends.server.types.ByteString;
import org.opends.server.types.ConfigChangeResult;
+import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DisconnectReason;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
-
-
import org.opends.server.types.InitializationException;
import org.opends.server.types.LockManager;
import org.opends.server.types.Privilege;
import org.opends.server.types.ResultCode;
import org.opends.server.util.Base64;
-import org.opends.server.types.DebugLogLevel;
+import static org.opends.messages.ExtensionMessages.*;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
-import static org.opends.messages.ExtensionMessages.*;
-
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -117,7 +113,7 @@
// The lock that will be used to provide threadsafe access to the message
// digest.
- private ReentrantLock digestLock;
+ private Object digestLock;
// The random number generator that we will use to create the nonce.
private SecureRandom randomGenerator;
@@ -151,7 +147,7 @@
// Initialize the variables needed for the MD5 digest creation.
- digestLock = new ReentrantLock();
+ digestLock = new Object();
randomGenerator = new SecureRandom();
try
@@ -1163,18 +1159,7 @@
private String generateNonce()
{
byte[] nonceBytes = new byte[16];
-
- digestLock.lock();
-
- try
- {
- randomGenerator.nextBytes(nonceBytes);
- }
- finally
- {
- digestLock.unlock();
- }
-
+ randomGenerator.nextBytes(nonceBytes);
return Base64.encode(nonceBytes);
}
@@ -1359,9 +1344,7 @@
String qop, String charset)
throws UnsupportedEncodingException
{
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
// First, get a hash of "username:realm:password".
StringBuilder a1String1 = new StringBuilder();
@@ -1423,10 +1406,6 @@
kdString.append(a2HashHex);
return md5Digest.digest(kdString.toString().getBytes(charset));
}
- finally
- {
- digestLock.unlock();
- }
}
@@ -1465,9 +1444,7 @@
String qop, String charset)
throws UnsupportedEncodingException
{
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
// First, get a hash of "username:realm:password".
StringBuilder a1String1 = new StringBuilder();
@@ -1534,10 +1511,6 @@
kdString.append(a2HashHex);
return md5Digest.digest(kdString.toString().getBytes(charset));
}
- finally
- {
- digestLock.unlock();
- }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/MD5PasswordStorageScheme.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/MD5PasswordStorageScheme.java
index dd2467e..a614ac1 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/MD5PasswordStorageScheme.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/MD5PasswordStorageScheme.java
@@ -30,7 +30,6 @@
import java.security.MessageDigest;
import java.util.Arrays;
-import java.util.concurrent.locks.ReentrantLock;
import org.opends.messages.Message;
import org.opends.server.admin.std.server.MD5PasswordStorageSchemeCfg;
@@ -83,7 +82,7 @@
private MessageDigest messageDigest;
// The lock used to provide threadsafe access to the message digest.
- private ReentrantLock digestLock;
+ private Object digestLock;
@@ -124,7 +123,7 @@
throw new InitializationException(message, e);
}
- digestLock = new ReentrantLock();
+ digestLock = new Object();
}
@@ -149,27 +148,24 @@
{
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- digestBytes = messageDigest.digest(plaintext.value());
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ digestBytes = messageDigest.digest(plaintext.value());
}
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
return ByteStringFactory.create(Base64.encode(digestBytes));
@@ -191,27 +187,24 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- digestBytes = messageDigest.digest(plaintext.value());
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ digestBytes = messageDigest.digest(plaintext.value());
}
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
buffer.append(Base64.encode(digestBytes));
@@ -231,24 +224,21 @@
{
byte[] userPWDigestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- userPWDigestBytes = messageDigest.digest(plaintextPassword.value());
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ userPWDigestBytes = messageDigest.digest(plaintextPassword.value());
}
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
- return false;
- }
- finally
- {
- digestLock.unlock();
+ return false;
+ }
}
byte[] storedPWDigestBytes;
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/RandomPasswordGenerator.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/RandomPasswordGenerator.java
index d910fb9..4bf784e 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/RandomPasswordGenerator.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/RandomPasswordGenerator.java
@@ -25,7 +25,6 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
package org.opends.server.extensions;
-import org.opends.messages.Message;
@@ -34,17 +33,19 @@
import java.util.List;
import java.util.SortedSet;
import java.util.StringTokenizer;
-import java.util.concurrent.locks.ReentrantLock;
+import org.opends.messages.Message;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.PasswordGeneratorCfg;
import org.opends.server.admin.std.server.RandomPasswordGeneratorCfg;
import org.opends.server.api.PasswordGenerator;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
+import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.ByteString;
import org.opends.server.types.ByteStringFactory;
import org.opends.server.types.ConfigChangeResult;
+import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -52,11 +53,8 @@
import org.opends.server.types.NamedCharacterSet;
import org.opends.server.types.ResultCode;
-import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
-import org.opends.server.types.DebugLogLevel;
import static org.opends.messages.ExtensionMessages.*;
-
+import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.server.util.StaticUtils.*;
@@ -97,7 +95,7 @@
// The lock to use to ensure that the character sets and counts are not
// altered while a password is being generated.
- private ReentrantLock generatorLock;
+ private Object generatorLock;
// The character set format string for this password generator.
private String formatString;
@@ -113,8 +111,7 @@
throws ConfigException, InitializationException
{
this.configEntryDN = configuration.dn();
- generatorLock = new ReentrantLock();
- int msgID ;
+ generatorLock = new Object();
// Get the character sets for use in generating the password. At least one
// must have been provided.
@@ -275,19 +272,13 @@
{
StringBuilder buffer = new StringBuilder(totalLength);
- generatorLock.lock();
-
- try
+ synchronized (generatorLock)
{
for (int i=0; i < characterSets.length; i++)
{
characterSets[i].getRandomCharacters(buffer, characterCounts[i]);
}
}
- finally
- {
- generatorLock.unlock();
- }
return ByteStringFactory.create(buffer.toString());
}
@@ -315,8 +306,6 @@
RandomPasswordGeneratorCfg configuration,
List<Message> unacceptableReasons)
{
- int msgID;
-
DN cfgEntryDN = configuration.dn();
// Get the character sets for use in generating the password. At
@@ -438,7 +427,6 @@
ResultCode resultCode = ResultCode.SUCCESS;
boolean adminActionRequired = false;
ArrayList<Message> messages = new ArrayList<Message>();
- int msgID;
// Get the character sets for use in generating the password. At least one
@@ -585,9 +573,7 @@
// If everything looks OK, then apply the changes.
if (resultCode == ResultCode.SUCCESS)
{
- generatorLock.lock();
-
- try
+ synchronized (generatorLock)
{
encodedCharacterSets = newEncodedCharacterSets;
formatString = newFormatString;
@@ -603,10 +589,6 @@
totalLength += characterCounts[i];
}
}
- finally
- {
- generatorLock.unlock();
- }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/SHA1PasswordStorageScheme.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/SHA1PasswordStorageScheme.java
index 1b85d79..d1c92ab 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/SHA1PasswordStorageScheme.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/SHA1PasswordStorageScheme.java
@@ -30,7 +30,6 @@
import java.security.MessageDigest;
import java.util.Arrays;
-import java.util.concurrent.locks.ReentrantLock;
import org.opends.messages.Message;
import org.opends.server.admin.std.server.SHA1PasswordStorageSchemeCfg;
@@ -83,7 +82,7 @@
private MessageDigest messageDigest;
// The lock used to provide threadsafe access to the message digest.
- private ReentrantLock digestLock;
+ private Object digestLock;
@@ -123,7 +122,7 @@
throw new InitializationException(message, e);
}
- digestLock = new ReentrantLock();
+ digestLock = new Object();
}
@@ -148,27 +147,24 @@
{
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- digestBytes = messageDigest.digest(plaintext.value());
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ digestBytes = messageDigest.digest(plaintext.value());
}
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
return ByteStringFactory.create(Base64.encode(digestBytes));
@@ -190,27 +186,24 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- digestBytes = messageDigest.digest(plaintext.value());
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ digestBytes = messageDigest.digest(plaintext.value());
}
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
buffer.append(Base64.encode(digestBytes));
@@ -229,24 +222,21 @@
{
byte[] userPWDigestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- userPWDigestBytes = messageDigest.digest(plaintextPassword.value());
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ userPWDigestBytes = messageDigest.digest(plaintextPassword.value());
}
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
- return false;
- }
- finally
- {
- digestLock.unlock();
+ return false;
+ }
}
byte[] storedPWDigestBytes;
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedMD5PasswordStorageScheme.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedMD5PasswordStorageScheme.java
index 9ac5196..753a054 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedMD5PasswordStorageScheme.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedMD5PasswordStorageScheme.java
@@ -31,7 +31,6 @@
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Random;
-import java.util.concurrent.locks.ReentrantLock;
import org.opends.messages.Message;
import org.opends.server.admin.std.server.SaltedMD5PasswordStorageSchemeCfg;
@@ -94,7 +93,7 @@
private MessageDigest messageDigest;
// The lock used to provide threadsafe access to the message digest.
- private ReentrantLock digestLock;
+ private Object digestLock;
// The secure random number generator to use to generate the salt values.
private Random random;
@@ -139,7 +138,7 @@
}
- digestLock = new ReentrantLock();
+ digestLock = new Object();
random = new Random();
}
@@ -171,33 +170,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
// Append the salt to the hashed value and base64-the whole thing.
@@ -232,33 +228,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
// Append the salt to the hashed value and base64-the whole thing.
@@ -317,24 +310,21 @@
byte[] userDigestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- userDigestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ userDigestBytes = messageDigest.digest(plainPlusSalt);
}
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
- return false;
- }
- finally
- {
- digestLock.unlock();
+ return false;
+ }
}
return Arrays.equals(digestBytes, userDigestBytes);
@@ -380,33 +370,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
@@ -454,17 +441,11 @@
System.arraycopy(saltBytes, 0, plainPlusSaltBytes, plainBytes.length,
saltBytes.length);
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
return Arrays.equals(digestBytes,
messageDigest.digest(plainPlusSaltBytes));
}
- finally
- {
- digestLock.unlock();
- }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA1PasswordStorageScheme.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA1PasswordStorageScheme.java
index 91e26d7..dba46f4 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA1PasswordStorageScheme.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA1PasswordStorageScheme.java
@@ -31,7 +31,6 @@
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Random;
-import java.util.concurrent.locks.ReentrantLock;
import org.opends.messages.Message;
import org.opends.server.admin.std.server.SaltedSHA1PasswordStorageSchemeCfg;
@@ -94,7 +93,7 @@
private MessageDigest messageDigest;
// The lock used to provide threadsafe access to the message digest.
- private ReentrantLock digestLock;
+ private Object digestLock;
// The secure random number generator to use to generate the salt values.
private Random random;
@@ -137,7 +136,7 @@
throw new InitializationException(message, e);
}
- digestLock = new ReentrantLock();
+ digestLock = new Object();
random = new Random();
}
@@ -169,33 +168,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
// Append the salt to the hashed value and base64-the whole thing.
@@ -230,33 +226,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
// Append the salt to the hashed value and base64-the whole thing.
@@ -315,24 +308,21 @@
byte[] userDigestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- userDigestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ userDigestBytes = messageDigest.digest(plainPlusSalt);
}
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
- return false;
- }
- finally
- {
- digestLock.unlock();
+ return false;
+ }
}
return Arrays.equals(digestBytes, userDigestBytes);
@@ -378,33 +368,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
@@ -452,17 +439,11 @@
System.arraycopy(saltBytes, 0, plainPlusSaltBytes, plainBytes.length,
saltBytes.length);
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
return Arrays.equals(digestBytes,
messageDigest.digest(plainPlusSaltBytes));
}
- finally
- {
- digestLock.unlock();
- }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA256PasswordStorageScheme.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA256PasswordStorageScheme.java
index 3b21156..06819ac 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA256PasswordStorageScheme.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA256PasswordStorageScheme.java
@@ -31,7 +31,6 @@
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Random;
-import java.util.concurrent.locks.ReentrantLock;
import org.opends.messages.Message;
import org.opends.server.admin.std.server.SaltedSHA256PasswordStorageSchemeCfg;
@@ -95,7 +94,7 @@
private MessageDigest messageDigest;
// The lock used to provide threadsafe access to the message digest.
- private ReentrantLock digestLock;
+ private Object digestLock;
// The secure random number generator to use to generate the salt values.
private Random random;
@@ -140,7 +139,7 @@
}
- digestLock = new ReentrantLock();
+ digestLock = new Object();
random = new Random();
}
@@ -172,33 +171,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
// Append the salt to the hashed value and base64-the whole thing.
@@ -233,33 +229,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
// Append the salt to the hashed value and base64-the whole thing.
@@ -318,24 +311,21 @@
byte[] userDigestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- userDigestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ userDigestBytes = messageDigest.digest(plainPlusSalt);
}
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
- return false;
- }
- finally
- {
- digestLock.unlock();
+ return false;
+ }
}
return Arrays.equals(digestBytes, userDigestBytes);
@@ -381,33 +371,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
@@ -455,17 +442,11 @@
System.arraycopy(saltBytes, 0, plainPlusSaltBytes, plainBytes.length,
saltBytes.length);
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
return Arrays.equals(digestBytes,
messageDigest.digest(plainPlusSaltBytes));
}
- finally
- {
- digestLock.unlock();
- }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA384PasswordStorageScheme.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA384PasswordStorageScheme.java
index 9f05505..321df14 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA384PasswordStorageScheme.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA384PasswordStorageScheme.java
@@ -31,7 +31,6 @@
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Random;
-import java.util.concurrent.locks.ReentrantLock;
import org.opends.messages.Message;
import org.opends.server.admin.std.server.SaltedSHA384PasswordStorageSchemeCfg;
@@ -95,7 +94,7 @@
private MessageDigest messageDigest;
// The lock used to provide threadsafe access to the message digest.
- private ReentrantLock digestLock;
+ private Object digestLock;
// The secure random number generator to use to generate the salt values.
private Random random;
@@ -140,7 +139,7 @@
}
- digestLock = new ReentrantLock();
+ digestLock = new Object();
random = new Random();
}
@@ -172,33 +171,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
// Append the salt to the hashed value and base64-the whole thing.
@@ -233,33 +229,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
// Append the salt to the hashed value and base64-the whole thing.
@@ -318,24 +311,21 @@
byte[] userDigestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- userDigestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ userDigestBytes = messageDigest.digest(plainPlusSalt);
}
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
- return false;
- }
- finally
- {
- digestLock.unlock();
+ return false;
+ }
}
return Arrays.equals(digestBytes, userDigestBytes);
@@ -381,33 +371,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
@@ -455,17 +442,11 @@
System.arraycopy(saltBytes, 0, plainPlusSaltBytes, plainBytes.length,
saltBytes.length);
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
return Arrays.equals(digestBytes,
messageDigest.digest(plainPlusSaltBytes));
}
- finally
- {
- digestLock.unlock();
- }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA512PasswordStorageScheme.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA512PasswordStorageScheme.java
index 793a30f..7f7fa69 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA512PasswordStorageScheme.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/SaltedSHA512PasswordStorageScheme.java
@@ -31,7 +31,6 @@
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Random;
-import java.util.concurrent.locks.ReentrantLock;
import org.opends.messages.Message;
import org.opends.server.admin.std.server.SaltedSHA512PasswordStorageSchemeCfg;
@@ -95,7 +94,7 @@
private MessageDigest messageDigest;
// The lock used to provide threadsafe access to the message digest.
- private ReentrantLock digestLock;
+ private Object digestLock;
// The secure random number generator to use to generate the salt values.
private Random random;
@@ -139,7 +138,7 @@
throw new InitializationException(message, e);
}
- digestLock = new ReentrantLock();
+ digestLock = new Object();
random = new Random();
}
@@ -171,33 +170,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
// Append the salt to the hashed value and base64-the whole thing.
@@ -232,33 +228,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
// Append the salt to the hashed value and base64-the whole thing.
@@ -317,24 +310,21 @@
byte[] userDigestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- userDigestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ userDigestBytes = messageDigest.digest(plainPlusSalt);
}
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
- return false;
- }
- finally
- {
- digestLock.unlock();
+ return false;
+ }
}
return Arrays.equals(digestBytes, userDigestBytes);
@@ -380,33 +370,30 @@
byte[] digestBytes;
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
- // Generate the salt and put in the plain+salt array.
- random.nextBytes(saltBytes);
- System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
- NUM_SALT_BYTES);
-
- // Create the hash from the concatenated value.
- digestBytes = messageDigest.digest(plainPlusSalt);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Generate the salt and put in the plain+salt array.
+ random.nextBytes(saltBytes);
+ System.arraycopy(saltBytes,0, plainPlusSalt, plainBytes.length,
+ NUM_SALT_BYTES);
- Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
- CLASS_NAME, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- digestLock.unlock();
+ // Create the hash from the concatenated value.
+ digestBytes = messageDigest.digest(plainPlusSalt);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(
+ CLASS_NAME, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
}
@@ -454,17 +441,11 @@
System.arraycopy(saltBytes, 0, plainPlusSaltBytes, plainBytes.length,
saltBytes.length);
- digestLock.lock();
-
- try
+ synchronized (digestLock)
{
return Arrays.equals(digestBytes,
messageDigest.digest(plainPlusSaltBytes));
}
- finally
- {
- digestLock.unlock();
- }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/TraditionalWorkQueue.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/TraditionalWorkQueue.java
index 75ae755..bec5d7e 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/TraditionalWorkQueue.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/TraditionalWorkQueue.java
@@ -25,7 +25,6 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
package org.opends.server.extensions;
-import org.opends.messages.Message;
@@ -36,14 +35,16 @@
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.ReentrantLock;
+import org.opends.messages.Message;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.TraditionalWorkQueueCfg;
import org.opends.server.api.WorkQueue;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
+import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.monitors.TraditionalWorkQueueMonitor;
+import org.opends.server.types.AbstractOperation;
import org.opends.server.types.CancelRequest;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DebugLogLevel;
@@ -53,12 +54,10 @@
import org.opends.server.types.Operation;
import org.opends.server.types.ResultCode;
-import static org.opends.server.loggers.ErrorLogger.*;
-import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.CoreMessages.*;
-import org.opends.server.types.AbstractOperation;
+import static org.opends.server.loggers.ErrorLogger.*;
+import static org.opends.server.loggers.debug.DebugLogger.*;
@@ -123,7 +122,7 @@
private LinkedBlockingQueue<AbstractOperation> opQueue;
// The lock used to provide threadsafe access for the queue.
- private ReentrantLock queueLock;
+ private Object queueLock;
@@ -149,7 +148,7 @@
killThreads = false;
opsSubmitted = new AtomicLong(0);
queueFullRejects = new AtomicLong(0);
- queueLock = new ReentrantLock();
+ queueLock = new Object();
// Register to be notified of any configuration changes.
@@ -354,38 +353,35 @@
// so, then return null and the thread will exit.
if (killThreads)
{
- queueLock.lock();
-
- try
+ synchronized (queueLock)
{
- int currentThreads = workerThreads.size();
- if (currentThreads > numWorkerThreads)
+ try
{
- if (workerThreads.remove(Thread.currentThread()))
+ int currentThreads = workerThreads.size();
+ if (currentThreads > numWorkerThreads)
{
- currentThreads--;
- }
+ if (workerThreads.remove(Thread.currentThread()))
+ {
+ currentThreads--;
+ }
- if (currentThreads <= numWorkerThreads)
- {
- killThreads = false;
- }
+ if (currentThreads <= numWorkerThreads)
+ {
+ killThreads = false;
+ }
- workerThread.setStoppedByReducedThreadNumber();
- return null;
+ workerThread.setStoppedByReducedThreadNumber();
+ return null;
+ }
}
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ catch (Exception e)
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
}
}
- finally
- {
- queueLock.unlock();
- }
}
if ((shutdownRequested) || (numFailures > MAX_RETRY_COUNT))
@@ -415,38 +411,35 @@
}
else if (killThreads)
{
- queueLock.lock();
-
- try
+ synchronized (queueLock)
{
- int currentThreads = workerThreads.size();
- if (currentThreads > numWorkerThreads)
+ try
{
- if (workerThreads.remove(Thread.currentThread()))
+ int currentThreads = workerThreads.size();
+ if (currentThreads > numWorkerThreads)
{
- currentThreads--;
- }
+ if (workerThreads.remove(Thread.currentThread()))
+ {
+ currentThreads--;
+ }
- if (currentThreads <= numWorkerThreads)
- {
- killThreads = false;
- }
+ if (currentThreads <= numWorkerThreads)
+ {
+ killThreads = false;
+ }
- workerThread.setStoppedByReducedThreadNumber();
- return null;
+ workerThread.setStoppedByReducedThreadNumber();
+ return null;
+ }
}
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ catch (Exception e)
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
}
}
- finally
- {
- queueLock.unlock();
- }
}
}
else
@@ -581,40 +574,37 @@
int currentThreads = workerThreads.size();
if (newNumThreads != currentThreads)
{
- queueLock.lock();
-
- try
+ synchronized (queueLock)
{
- int threadsToAdd = newNumThreads - currentThreads;
- if (threadsToAdd > 0)
+ try
{
- for (int i=0; i < threadsToAdd; i++)
+ int threadsToAdd = newNumThreads - currentThreads;
+ if (threadsToAdd > 0)
{
- TraditionalWorkerThread t =
- new TraditionalWorkerThread(this, lastThreadNumber++);
- workerThreads.add(t);
- t.start();
+ for (int i=0; i < threadsToAdd; i++)
+ {
+ TraditionalWorkerThread t =
+ new TraditionalWorkerThread(this, lastThreadNumber++);
+ workerThreads.add(t);
+ t.start();
+ }
+
+ killThreads = false;
+ }
+ else
+ {
+ killThreads = true;
}
- killThreads = false;
+ numWorkerThreads = newNumThreads;
}
- else
+ catch (Exception e)
{
- killThreads = true;
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
}
-
- numWorkerThreads = newNumThreads;
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- finally
- {
- queueLock.unlock();
}
}
@@ -626,68 +616,65 @@
// checks will be against the new queue.
if (newMaxCapacity != maxCapacity)
{
- queueLock.lock();
-
- try
+ synchronized (queueLock)
{
- LinkedBlockingQueue<AbstractOperation> newOpQueue;
- if (newMaxCapacity > 0)
+ try
{
- newOpQueue =
- new LinkedBlockingQueue<AbstractOperation>(newMaxCapacity);
- }
- else
- {
- newOpQueue = new LinkedBlockingQueue<AbstractOperation>();
- }
-
- LinkedBlockingQueue<AbstractOperation> oldOpQueue = opQueue;
- opQueue = newOpQueue;
-
- LinkedList<AbstractOperation> pendingOps =
- new LinkedList<AbstractOperation>();
- oldOpQueue.drainTo(pendingOps);
-
-
- // We have to be careful when adding any existing pending operations
- // because the new capacity could be less than what was already
- // backlogged in the previous queue. If that happens, we may have to
- // loop a few times to get everything in there.
- while (! pendingOps.isEmpty())
- {
- Iterator<AbstractOperation> iterator = pendingOps.iterator();
- while (iterator.hasNext())
+ LinkedBlockingQueue<AbstractOperation> newOpQueue;
+ if (newMaxCapacity > 0)
{
- AbstractOperation o = iterator.next();
- try
+ newOpQueue =
+ new LinkedBlockingQueue<AbstractOperation>(newMaxCapacity);
+ }
+ else
+ {
+ newOpQueue = new LinkedBlockingQueue<AbstractOperation>();
+ }
+
+ LinkedBlockingQueue<AbstractOperation> oldOpQueue = opQueue;
+ opQueue = newOpQueue;
+
+ LinkedList<AbstractOperation> pendingOps =
+ new LinkedList<AbstractOperation>();
+ oldOpQueue.drainTo(pendingOps);
+
+
+ // We have to be careful when adding any existing pending operations
+ // because the new capacity could be less than what was already
+ // backlogged in the previous queue. If that happens, we may have to
+ // loop a few times to get everything in there.
+ while (! pendingOps.isEmpty())
+ {
+ Iterator<AbstractOperation> iterator = pendingOps.iterator();
+ while (iterator.hasNext())
{
- if (newOpQueue.offer(o, 1000, TimeUnit.MILLISECONDS))
+ AbstractOperation o = iterator.next();
+ try
{
- iterator.remove();
+ if (newOpQueue.offer(o, 1000, TimeUnit.MILLISECONDS))
+ {
+ iterator.remove();
+ }
}
- }
- catch (InterruptedException ie)
- {
- if (debugEnabled())
+ catch (InterruptedException ie)
{
- TRACER.debugCaught(DebugLogLevel.ERROR, ie);
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, ie);
+ }
}
}
}
- }
- maxCapacity = newMaxCapacity;
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ maxCapacity = newMaxCapacity;
}
- }
- finally
- {
- queueLock.unlock();
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+ }
}
}
@@ -708,9 +695,7 @@
return false;
}
- queueLock.lock();
-
- try
+ synchronized (queueLock)
{
for (TraditionalWorkerThread t : workerThreads)
{
@@ -722,10 +707,6 @@
return true;
}
- finally
- {
- queueLock.unlock();
- }
}
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/loggers/AsyncronousTextWriter.java b/opendj-sdk/opends/src/server/org/opends/server/loggers/AsyncronousTextWriter.java
index ea61eee..c40f42f 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/loggers/AsyncronousTextWriter.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/loggers/AsyncronousTextWriter.java
@@ -25,16 +25,20 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
package org.opends.server.loggers;
-import org.opends.messages.Message;
+
+
+import java.util.ArrayList;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.opends.messages.Message;
import org.opends.server.api.DirectoryThread;
import org.opends.server.api.ServerShutdownListener;
import org.opends.server.core.DirectoryServer;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
/**
* A Text Writer which writes log records asynchronously to
@@ -51,6 +55,9 @@
/** Queue to store unpublished records. */
private final LinkedBlockingQueue<String> queue;
+ /** The capacity for the queue. */
+ private final int capacity;
+
private String name;
private AtomicBoolean stopRequested;
private WriterThread writerThread;
@@ -74,6 +81,7 @@
this.writer = writer;
this.queue = new LinkedBlockingQueue<String>(capacity);
+ this.capacity = capacity;
this.writerThread = null;
this.stopRequested = new AtomicBoolean(false);
@@ -99,21 +107,40 @@
*/
public void run()
{
+ ArrayList<String> drainList = new ArrayList<String>(capacity);
+
String message = null;
while (!stopRequested.get() || !queue.isEmpty()) {
try
{
- message = queue.poll(10, TimeUnit.SECONDS);
- if(message != null)
+ queue.drainTo(drainList, capacity);
+ if (drainList.isEmpty())
{
- do
+ message = queue.poll(10, TimeUnit.SECONDS);
+ if(message != null)
{
- writer.writeRecord(message);
- message = queue.poll();
- }
- while(message != null);
+ do
+ {
+ writer.writeRecord(message);
+ message = queue.poll();
+ }
+ while(message != null);
- if(autoFlush)
+ if(autoFlush)
+ {
+ flush();
+ }
+ }
+ }
+ else
+ {
+ for (String record : drainList)
+ {
+ writer.writeRecord(record);
+ }
+ drainList.clear();
+
+ if (autoFlush)
{
flush();
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
index 28037e4..53acdb8 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
@@ -39,7 +39,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.locks.ReentrantLock;
import org.opends.messages.Message;
import org.opends.messages.MessageBuilder;
@@ -190,10 +189,10 @@
// The lock used to provide threadsafe access to the set of operations in
// progress.
- private ReentrantLock opsInProgressLock;
+ private Object opsInProgressLock;
// The lock used to provide threadsafe access when sending data to the client.
- private ReentrantLock transmitLock;
+ private Object transmitLock;
// The socket channel with which this client connection is associated.
private SocketChannel clientChannel;
@@ -234,8 +233,8 @@
this.securityProvider = null;
this.clearSecurityProvider = null;
- opsInProgressLock = new ReentrantLock();
- transmitLock = new ReentrantLock();
+ opsInProgressLock = new Object();
+ transmitLock = new Object();
elementReadState = ELEMENT_READ_STATE_NEED_TYPE;
elementType = 0x00;
@@ -874,60 +873,57 @@
// Make sure that we can only send one message at a time. This locking will
// not have any impact on the ability to read requests from the client.
- transmitLock.lock();
-
- try
+ synchronized (transmitLock)
{
try
{
- int bytesWritten = messageBuffer.limit() - messageBuffer.position();
- if (! secProvider.writeData(messageBuffer))
+ try
{
+ int bytesWritten = messageBuffer.limit() - messageBuffer.position();
+ if (! secProvider.writeData(messageBuffer))
+ {
+ return;
+ }
+
+ TRACER.debugProtocolElement(DebugLogLevel.VERBOSE, message);
+ TRACER.debugProtocolElement(DebugLogLevel.VERBOSE, messageElement);
+
+ messageBuffer.rewind();
+ if (debugEnabled())
+ {
+ TRACER.debugData(DebugLogLevel.VERBOSE, messageBuffer);
+ }
+
+ if (keepStats)
+ {
+ statTracker.updateMessageWritten(message, bytesWritten);
+ }
+ }
+ catch (@Deprecated Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ // We were unable to send the message due to some other internal
+ // problem. Disconnect from the client and return.
+ disconnect(DisconnectReason.SERVER_ERROR, true, null);
return;
}
-
- TRACER.debugProtocolElement(DebugLogLevel.VERBOSE, message);
- TRACER.debugProtocolElement(DebugLogLevel.VERBOSE, messageElement);
-
- messageBuffer.rewind();
- if (debugEnabled())
- {
- TRACER.debugData(DebugLogLevel.VERBOSE, messageBuffer);
- }
-
- if (keepStats)
- {
- statTracker.updateMessageWritten(message, bytesWritten);
- }
}
- catch (@Deprecated Exception e)
+ catch (Exception e)
{
if (debugEnabled())
{
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
- // We were unable to send the message due to some other internal
- // problem. Disconnect from the client and return.
+ // FIXME -- Log a message or something
disconnect(DisconnectReason.SERVER_ERROR, true, null);
return;
}
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
-
- // FIXME -- Log a message or something
- disconnect(DisconnectReason.SERVER_ERROR, true, null);
- return;
- }
- finally
- {
- transmitLock.unlock();
- }
}
@@ -974,22 +970,19 @@
// Set a flag indicating that the connection is being terminated so that no
// new requests will be accepted. Also cancel all operations in progress.
- opsInProgressLock.lock();
-
- try
+ synchronized (opsInProgressLock)
{
- disconnectRequested = true;
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ disconnectRequested = true;
}
- }
- finally
- {
- opsInProgressLock.unlock();
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+ }
}
cancelAllOperations(new CancelRequest(true, message));
@@ -1174,64 +1167,63 @@
// We need to grab a lock to ensure that no one else can add operations to
// the queue while we are performing some preliminary checks.
- opsInProgressLock.lock();
-
- try
+ synchronized (opsInProgressLock)
{
- // If we're already in the process of disconnecting the client, then
- // reject the operation.
- if (disconnectRequested)
+ try
{
- Message message = WARN_LDAP_CLIENT_DISCONNECT_IN_PROGRESS.get();
- throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
+ // If we're already in the process of disconnecting the client, then
+ // reject the operation.
+ if (disconnectRequested)
+ {
+ Message message = WARN_LDAP_CLIENT_DISCONNECT_IN_PROGRESS.get();
+ throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
+ message);
+ }
+
+
+ // See if there is already an operation in progress with the same
+ // message ID. If so, then we can't allow it.
+ AbstractOperation op = operationsInProgress.get(messageID);
+ if (op != null)
+ {
+ Message message =
+ WARN_LDAP_CLIENT_DUPLICATE_MESSAGE_ID.get(messageID);
+ throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message);
+ }
+
+
+ // Add the operation to the list of operations in progress for this
+ // connection.
+ operationsInProgress.put(messageID, operation);
+
+
+ // Try to add the operation to the work queue.
+ DirectoryServer.enqueueRequest(operation);
}
-
-
- // See if there is already an operation in progress with the same message
- // ID. If so, then we can't allow it.
- AbstractOperation op = operationsInProgress.get(messageID);
- if (op != null)
+ catch (DirectoryException de)
{
- Message message = WARN_LDAP_CLIENT_DUPLICATE_MESSAGE_ID.get(messageID);
- throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message);
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, de);
+ }
+
+ operationsInProgress.remove(messageID);
+ lastCompletionTime.set(TimeThread.getTime());
+
+ throw de;
}
-
-
- // Add the operation to the list of operations in progress for this
- // connection.
- operationsInProgress.put(messageID, operation);
-
-
- // Try to add the operation to the work queue.
- DirectoryServer.enqueueRequest(operation);
- }
- catch (DirectoryException de)
- {
- if (debugEnabled())
+ catch (Exception e)
{
- TRACER.debugCaught(DebugLogLevel.ERROR, de);
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message =
+ WARN_LDAP_CLIENT_CANNOT_ENQUEUE.get(getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
}
-
- operationsInProgress.remove(messageID);
- lastCompletionTime.set(TimeThread.getTime());
-
- throw de;
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
-
- Message message =
- WARN_LDAP_CLIENT_CANNOT_ENQUEUE.get(getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, e);
- }
- finally
- {
- opsInProgressLock.unlock();
}
}
@@ -1322,84 +1314,11 @@
public void cancelAllOperations(CancelRequest cancelRequest)
{
// Make sure that no one can add any new operations.
- opsInProgressLock.lock();
-
- try
+ synchronized (opsInProgressLock)
{
- for (AbstractOperation o : operationsInProgress.values())
+ try
{
- try
- {
- CancelResult cancelResult = o.cancel(cancelRequest);
- if (keepStats && (cancelResult == CancelResult.CANCELED))
- {
- statTracker.updateAbandonedOperation();
- }
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- }
-
- if (! (operationsInProgress.isEmpty() &&
- getPersistentSearches().isEmpty()))
- {
- lastCompletionTime.set(TimeThread.getTime());
- }
-
- operationsInProgress.clear();
-
-
- for (PersistentSearch persistentSearch : getPersistentSearches())
- {
- DirectoryServer.deregisterPersistentSearch(persistentSearch);
- }
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- finally
- {
- opsInProgressLock.unlock();
- }
- }
-
-
-
- /**
- * Attempts to cancel all operations in progress on this connection except the
- * operation with the specified message ID.
- *
- * @param cancelRequest An object providing additional information about how
- * the cancel should be processed.
- * @param messageID The message ID of the operation that should not be
- * canceled.
- */
- public void cancelAllOperationsExcept(CancelRequest cancelRequest,
- int messageID)
- {
- // Make sure that no one can add any new operations.
- opsInProgressLock.lock();
-
- try
- {
- for (int msgID : operationsInProgress.keySet())
- {
- if (msgID == messageID)
- {
- continue;
- }
-
- AbstractOperation o = operationsInProgress.get(msgID);
- if (o != null)
+ for (AbstractOperation o : operationsInProgress.values())
{
try
{
@@ -1418,27 +1337,94 @@
}
}
- operationsInProgress.remove(msgID);
- lastCompletionTime.set(TimeThread.getTime());
- }
+ if (! (operationsInProgress.isEmpty() &&
+ getPersistentSearches().isEmpty()))
+ {
+ lastCompletionTime.set(TimeThread.getTime());
+ }
+
+ operationsInProgress.clear();
- for (PersistentSearch persistentSearch : getPersistentSearches())
+ for (PersistentSearch persistentSearch : getPersistentSearches())
+ {
+ DirectoryServer.deregisterPersistentSearch(persistentSearch);
+ }
+ }
+ catch (Exception e)
{
- DirectoryServer.deregisterPersistentSearch(persistentSearch);
- lastCompletionTime.set(TimeThread.getTime());
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
}
}
- catch (Exception e)
+ }
+
+
+
+ /**
+ * Attempts to cancel all operations in progress on this connection except the
+ * operation with the specified message ID.
+ *
+ * @param cancelRequest An object providing additional information about how
+ * the cancel should be processed.
+ * @param messageID The message ID of the operation that should not be
+ * canceled.
+ */
+ public void cancelAllOperationsExcept(CancelRequest cancelRequest,
+ int messageID)
+ {
+ // Make sure that no one can add any new operations.
+ synchronized (opsInProgressLock)
{
- if (debugEnabled())
+ try
{
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ for (int msgID : operationsInProgress.keySet())
+ {
+ if (msgID == messageID)
+ {
+ continue;
+ }
+
+ AbstractOperation o = operationsInProgress.get(msgID);
+ if (o != null)
+ {
+ try
+ {
+ CancelResult cancelResult = o.cancel(cancelRequest);
+ if (keepStats && (cancelResult == CancelResult.CANCELED))
+ {
+ statTracker.updateAbandonedOperation();
+ }
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+ }
+ }
+
+ operationsInProgress.remove(msgID);
+ lastCompletionTime.set(TimeThread.getTime());
+ }
+
+
+ for (PersistentSearch persistentSearch : getPersistentSearches())
+ {
+ DirectoryServer.deregisterPersistentSearch(persistentSearch);
+ lastCompletionTime.set(TimeThread.getTime());
+ }
}
- }
- finally
- {
- opsInProgressLock.unlock();
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+ }
}
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java
index 360e339..ec0947c 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java
@@ -25,27 +25,26 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
package org.opends.server.protocols.ldap;
-import org.opends.messages.Message;
import java.util.ArrayList;
import java.util.LinkedHashSet;
-import java.util.concurrent.locks.ReentrantLock;
+import org.opends.messages.Message;
import org.opends.server.admin.std.server.MonitorProviderCfg;
import org.opends.server.api.MonitorProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.config.ConfigException;
+import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.DebugLogLevel;
-import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
import static org.opends.messages.ProtocolMessages.*;
+import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
@@ -120,11 +119,11 @@
// The locks used to provide threadsafe access to this class. In this case,
// read and write refer to the type of LDAP communication, not access to the
// protected data.
- private ReentrantLock abandonLock;
- private ReentrantLock connectLock;
- private ReentrantLock disconnectLock;
- private ReentrantLock readLock;
- private ReentrantLock writeLock;
+ private Object abandonLock;
+ private Object connectLock;
+ private Object disconnectLock;
+ private Object readLock;
+ private Object writeLock;
// The instance name for this monitor provider instance.
private String instanceName;
@@ -162,11 +161,11 @@
this.instanceName = instanceName;
this.parent = parent;
- abandonLock = new ReentrantLock();
- connectLock = new ReentrantLock();
- disconnectLock = new ReentrantLock();
- readLock = new ReentrantLock();
- writeLock = new ReentrantLock();
+ abandonLock = new Object();
+ connectLock = new Object();
+ disconnectLock = new Object();
+ readLock = new Object();
+ writeLock = new Object();
abandonRequests = 0;
addRequests = 0;
@@ -307,25 +306,15 @@
// Quickly grab the locks and store consistent copies of the information.
// Note that when grabbing multiple locks, it is essential that they are all
// acquired in the same order to prevent deadlocks.
- abandonLock.lock();
-
- try
+ synchronized (abandonLock)
{
- connectLock.lock();
-
- try
+ synchronized (connectLock)
{
- disconnectLock.lock();
-
- try
+ synchronized (disconnectLock)
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
tmpAbandonRequests = abandonRequests;
tmpAddRequests = addRequests;
@@ -357,74 +346,9 @@
tmpSearchResultsDone = searchResultsDone;
tmpUnbindRequests = unbindRequests;
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
-
- return attrs;
- }
- finally
- {
- readLock.unlock();
- }
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
-
- return attrs;
- }
- finally
- {
- writeLock.unlock();
}
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
-
- return attrs;
- }
- finally
- {
- disconnectLock.unlock();
- }
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
-
- return attrs;
- }
- finally
- {
- connectLock.unlock();
- }
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
-
- return attrs;
- }
- finally
- {
- abandonLock.unlock();
}
@@ -496,25 +420,15 @@
// Quickly grab the locks and store consistent copies of the information.
// Note that when grabbing multiple locks, it is essential that they are all
// acquired in the same order to prevent deadlocks.
- abandonLock.lock();
-
- try
+ synchronized (abandonLock)
{
- connectLock.lock();
-
- try
+ synchronized (connectLock)
{
- disconnectLock.lock();
-
- try
+ synchronized (disconnectLock)
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
abandonRequests = 0;
addRequests = 0;
@@ -546,64 +460,9 @@
searchResultsDone = 0;
unbindRequests = 0;
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- finally
- {
- readLock.unlock();
- }
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- finally
- {
- writeLock.unlock();
}
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- finally
- {
- disconnectLock.unlock();
- }
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- finally
- {
- connectLock.unlock();
- }
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- finally
- {
- abandonLock.unlock();
}
}
@@ -615,23 +474,10 @@
*/
public void updateConnect()
{
- connectLock.lock();
-
- try
+ synchronized (connectLock)
{
connectionsEstablished++;
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- finally
- {
- connectLock.unlock();
- }
// Update the parent if there is one.
if (parent != null)
@@ -648,23 +494,10 @@
*/
public void updateDisconnect()
{
- disconnectLock.lock();
-
- try
+ synchronized (disconnectLock)
{
connectionsClosed++;
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- finally
- {
- disconnectLock.unlock();
- }
// Update the parent if there is one.
if (parent != null)
@@ -683,23 +516,10 @@
*/
public void updateBytesRead(int bytesRead)
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
this.bytesRead += bytesRead;
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- finally
- {
- readLock.unlock();
- }
// Update the parent if there is one.
if (parent != null)
@@ -718,9 +538,7 @@
*/
public void updateMessageRead(LDAPMessage message)
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
messagesRead++;
operationsInitiated++;
@@ -759,17 +577,6 @@
break;
}
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- finally
- {
- readLock.unlock();
- }
// Update the parent if there is one.
if (parent != null)
@@ -789,9 +596,7 @@
*/
public void updateMessageWritten(LDAPMessage message, int bytesWritten)
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
this.bytesWritten += bytesWritten;
messagesWritten++;
@@ -844,17 +649,6 @@
break;
}
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- finally
- {
- writeLock.unlock();
- }
// Update the parent if there is one.
if (parent != null)
@@ -871,23 +665,10 @@
*/
public void updateAbandonedOperation()
{
- abandonLock.lock();
-
- try
+ synchronized (abandonLock)
{
operationsAbandoned++;
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- finally
- {
- abandonLock.unlock();
- }
// Update the parent if there is one.
if (parent != null)
@@ -941,16 +722,10 @@
*/
public long getConnectionsEstablished()
{
- connectLock.lock();
-
- try
+ synchronized (connectLock)
{
return connectionsEstablished;
}
- finally
- {
- connectLock.unlock();
- }
}
@@ -962,16 +737,10 @@
*/
public long getConnectionsClosed()
{
- disconnectLock.lock();
-
- try
+ synchronized (disconnectLock)
{
return connectionsClosed;
}
- finally
- {
- disconnectLock.unlock();
- }
}
@@ -983,16 +752,10 @@
*/
public long getBytesRead()
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
return bytesRead;
}
- finally
- {
- readLock.unlock();
- }
}
@@ -1004,16 +767,10 @@
*/
public long getBytesWritten()
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
return bytesWritten;
}
- finally
- {
- writeLock.unlock();
- }
}
@@ -1025,16 +782,10 @@
*/
public long getMessagesRead()
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
return messagesRead;
}
- finally
- {
- readLock.unlock();
- }
}
@@ -1046,16 +797,10 @@
*/
public long getMessagesWritten()
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
return messagesWritten;
}
- finally
- {
- writeLock.unlock();
- }
}
@@ -1067,16 +812,10 @@
*/
public long getOperationsInitiated()
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
return operationsInitiated;
}
- finally
- {
- readLock.unlock();
- }
}
@@ -1090,16 +829,10 @@
*/
public long getOperationsCompleted()
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
return operationsCompleted;
}
- finally
- {
- writeLock.unlock();
- }
}
@@ -1111,16 +844,10 @@
*/
public long getOperationsAbandoned()
{
- abandonLock.lock();
-
- try
+ synchronized (abandonLock)
{
return operationsAbandoned;
}
- finally
- {
- abandonLock.unlock();
- }
}
@@ -1132,16 +859,10 @@
*/
public long getAbandonRequests()
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
return abandonRequests;
}
- finally
- {
- readLock.unlock();
- }
}
@@ -1153,16 +874,10 @@
*/
public long getAddRequests()
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
return addRequests;
}
- finally
- {
- readLock.unlock();
- }
}
@@ -1174,16 +889,10 @@
*/
public long getAddResponses()
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
return addResponses;
}
- finally
- {
- writeLock.unlock();
- }
}
@@ -1195,16 +904,10 @@
*/
public long getBindRequests()
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
return bindRequests;
}
- finally
- {
- readLock.unlock();
- }
}
@@ -1216,16 +919,10 @@
*/
public long getBindResponses()
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
return bindResponses;
}
- finally
- {
- writeLock.unlock();
- }
}
@@ -1237,16 +934,10 @@
*/
public long getCompareRequests()
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
return compareRequests;
}
- finally
- {
- readLock.unlock();
- }
}
@@ -1258,16 +949,10 @@
*/
public long getCompareResponses()
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
return compareResponses;
}
- finally
- {
- writeLock.unlock();
- }
}
@@ -1279,16 +964,10 @@
*/
public long getDeleteRequests()
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
return deleteRequests;
}
- finally
- {
- readLock.unlock();
- }
}
@@ -1300,16 +979,10 @@
*/
public long getDeleteResponses()
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
return deleteResponses;
}
- finally
- {
- writeLock.unlock();
- }
}
@@ -1321,16 +994,10 @@
*/
public long getExtendedRequests()
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
return extendedRequests;
}
- finally
- {
- readLock.unlock();
- }
}
@@ -1342,16 +1009,10 @@
*/
public long getExtendedResponses()
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
return extendedResponses;
}
- finally
- {
- writeLock.unlock();
- }
}
@@ -1363,16 +1024,10 @@
*/
public long getModifyRequests()
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
return modifyRequests;
}
- finally
- {
- readLock.unlock();
- }
}
@@ -1384,16 +1039,10 @@
*/
public long getModifyResponses()
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
return modifyResponses;
}
- finally
- {
- writeLock.unlock();
- }
}
@@ -1405,16 +1054,10 @@
*/
public long getModifyDNRequests()
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
return modifyDNRequests;
}
- finally
- {
- readLock.unlock();
- }
}
@@ -1426,16 +1069,10 @@
*/
public long getModifyDNResponses()
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
return modifyDNResponses;
}
- finally
- {
- writeLock.unlock();
- }
}
@@ -1447,16 +1084,10 @@
*/
public long getSearchRequests()
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
return searchRequests;
}
- finally
- {
- readLock.unlock();
- }
}
@@ -1468,16 +1099,10 @@
*/
public long getSearchResultEntries()
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
return searchResultEntries;
}
- finally
- {
- writeLock.unlock();
- }
}
@@ -1489,16 +1114,10 @@
*/
public long getSearchResultReferences()
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
return searchResultReferences;
}
- finally
- {
- writeLock.unlock();
- }
}
@@ -1510,16 +1129,10 @@
*/
public long getSearchResultsDone()
{
- writeLock.lock();
-
- try
+ synchronized (writeLock)
{
return searchResultsDone;
}
- finally
- {
- writeLock.unlock();
- }
}
@@ -1531,16 +1144,10 @@
*/
public long getUnbindRequests()
{
- readLock.lock();
-
- try
+ synchronized (readLock)
{
return unbindRequests;
}
- finally
- {
- readLock.unlock();
- }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeEqualityMatchingRule.java b/opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeEqualityMatchingRule.java
index 3ea5b80..7bece4d 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeEqualityMatchingRule.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeEqualityMatchingRule.java
@@ -28,23 +28,19 @@
-import java.text.SimpleDateFormat;
-import java.util.TimeZone;
-import java.util.concurrent.locks.ReentrantLock;
-
import org.opends.server.admin.std.server.EqualityMatchingRuleCfg;
import org.opends.server.api.EqualityMatchingRule;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
+import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.types.ByteString;
+import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
-import org.opends.server.types.DebugLogLevel;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.ServerConstants.*;
@@ -61,44 +57,6 @@
*/
private static final DebugTracer TRACER = getTracer();
- /**
- * The lock that will be used to provide threadsafe access to the date
- * formatter.
- */
- private static ReentrantLock dateFormatLock;
-
-
-
- /**
- * The date formatter that will be used to convert dates into generalized time
- * values. Note that all interaction with it must be synchronized.
- */
- private static SimpleDateFormat dateFormat;
-
-
-
- /**
- * The time zone used for UTC time.
- */
- private static TimeZone utcTimeZone;
-
-
-
- /*
- * Create the date formatter that will be used to construct and parse
- * normalized generalized time values.
- */
- static
- {
- utcTimeZone = TimeZone.getTimeZone("UTC");
-
- dateFormat = new SimpleDateFormat(DATE_FORMAT_GENERALIZED_TIME);
- dateFormat.setLenient(false);
- dateFormat.setTimeZone(utcTimeZone);
-
- dateFormatLock = new ReentrantLock();
- }
-
/**
diff --git a/opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeOrderingMatchingRule.java b/opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeOrderingMatchingRule.java
index 774d218..cce8627 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeOrderingMatchingRule.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeOrderingMatchingRule.java
@@ -28,29 +28,24 @@
-import java.text.SimpleDateFormat;
-import java.util.TimeZone;
-import java.util.concurrent.locks.ReentrantLock;
-
import org.opends.server.admin.std.server.OrderingMatchingRuleCfg;
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
+import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.types.ByteString;
+import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.DirectoryException;
-
-
import org.opends.server.types.InitializationException;
-import org.opends.server.types.DebugLogLevel;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.ServerConstants.*;
+
/**
* This class defines the generalizedTimeOrderingMatch matching rule defined in
* X.520 and referenced in RFC 2252.
@@ -63,6 +58,8 @@
*/
private static final DebugTracer TRACER = getTracer();
+
+
/**
* The serial version identifier required to satisfy the compiler because this
* class implements the <CODE>java.io.Serializable</CODE> interface. This
@@ -74,46 +71,6 @@
/**
- * The lock that will be used to provide threadsafe access to the date
- * formatter.
- */
- private static ReentrantLock dateFormatLock;
-
-
-
- /**
- * The date formatter that will be used to convert dates into generalized time
- * values. Note that all interaction with it must be synchronized.
- */
- private static SimpleDateFormat dateFormat;
-
-
-
- /**
- * The time zone used for UTC time.
- */
- private static TimeZone utcTimeZone;
-
-
-
- /*
- * Create the date formatter that will be used to construct and parse
- * normalized generalized time values.
- */
- static
- {
- utcTimeZone = TimeZone.getTimeZone("UTC");
-
- dateFormat = new SimpleDateFormat(DATE_FORMAT_GENERALIZED_TIME);
- dateFormat.setLenient(false);
- dateFormat.setTimeZone(utcTimeZone);
-
- dateFormatLock = new ReentrantLock();
- }
-
-
-
- /**
* Creates a new instance of this generalizedTimeMatch matching rule.
*/
public GeneralizedTimeOrderingMatchingRule()
diff --git a/opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeSyntax.java b/opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeSyntax.java
index 1950fbf..cf06c65 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeSyntax.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/schema/GeneralizedTimeSyntax.java
@@ -25,7 +25,6 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
package org.opends.server.schema;
-import org.opends.messages.Message;
@@ -34,8 +33,9 @@
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
-import java.util.concurrent.locks.ReentrantLock;
+import org.opends.messages.Message;
+import org.opends.messages.MessageBuilder;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.ApproximateMatchingRule;
import org.opends.server.api.AttributeSyntax;
@@ -44,20 +44,17 @@
import org.opends.server.api.SubstringMatchingRule;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
+import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.ByteString;
+import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.DirectoryException;
-
-
import org.opends.server.types.ResultCode;
-import org.opends.server.types.DebugLogLevel;
+import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
-import static org.opends.messages.SchemaMessages.*;
-import org.opends.messages.MessageBuilder;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.ServerConstants.*;
@@ -82,7 +79,7 @@
* The lock that will be used to provide threadsafe access to the date
* formatter.
*/
- private static ReentrantLock dateFormatLock;
+ private static Object dateFormatLock;
@@ -115,7 +112,7 @@
dateFormat.setLenient(false);
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- dateFormatLock = new ReentrantLock();
+ dateFormatLock = new Object();
}
@@ -301,16 +298,10 @@
*/
public static String format(Date d)
{
- dateFormatLock.lock();
-
- try
+ synchronized (dateFormatLock)
{
return dateFormat.format(d);
}
- finally
- {
- dateFormatLock.unlock();
- }
}
@@ -324,16 +315,10 @@
*/
public static String format(long t)
{
- dateFormatLock.lock();
-
- try
+ synchronized (dateFormatLock)
{
return dateFormat.format(new Date(t));
}
- finally
- {
- dateFormatLock.unlock();
- }
}
@@ -351,26 +336,10 @@
{
String valueString;
- dateFormatLock.lock();
-
- try
+ synchronized (dateFormatLock)
{
valueString = dateFormat.format(new Date(time));
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
-
- // This should never happen.
- valueString = null;
- }
- finally
- {
- dateFormatLock.unlock();
- }
return new AttributeValue(new ASN1OctetString(valueString),
new ASN1OctetString(valueString));
diff --git a/opendj-sdk/opends/src/server/org/opends/server/schema/UTCTimeSyntax.java b/opendj-sdk/opends/src/server/org/opends/server/schema/UTCTimeSyntax.java
index fcd0ca1..5b84536 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/schema/UTCTimeSyntax.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/schema/UTCTimeSyntax.java
@@ -25,15 +25,15 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
package org.opends.server.schema;
-import org.opends.messages.Message;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
-import java.util.concurrent.locks.ReentrantLock;
+import org.opends.messages.Message;
+import org.opends.messages.MessageBuilder;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.ApproximateMatchingRule;
import org.opends.server.api.AttributeSyntax;
@@ -42,20 +42,17 @@
import org.opends.server.api.SubstringMatchingRule;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
+import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.ByteString;
+import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.DirectoryException;
-
-
import org.opends.server.types.ResultCode;
-import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
-import static org.opends.server.loggers.ErrorLogger.*;
-import org.opends.server.types.DebugLogLevel;
import static org.opends.messages.SchemaMessages.*;
-import org.opends.messages.MessageBuilder;
+import static org.opends.server.loggers.debug.DebugLogger.*;
+import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.ServerConstants.*;
@@ -83,7 +80,7 @@
* The lock that will be used to provide threadsafe access to the date
* formatter.
*/
- private static ReentrantLock dateFormatLock;
+ private static Object dateFormatLock;
@@ -116,7 +113,7 @@
dateFormat.setLenient(false);
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- dateFormatLock = new ReentrantLock();
+ dateFormatLock = new Object();
}
@@ -844,26 +841,10 @@
{
String valueString;
- dateFormatLock.lock();
-
- try
+ synchronized (dateFormatLock)
{
valueString = dateFormat.format(d);
}
- catch (Exception e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
-
- // This should never happen.
- valueString = null;
- }
- finally
- {
- dateFormatLock.unlock();
- }
return new AttributeValue(new ASN1OctetString(valueString),
new ASN1OctetString(valueString));
@@ -890,21 +871,10 @@
String valueString = normalizedValue.stringValue();
try
{
- dateFormatLock.lock();
-
- try
+ synchronized (dateFormatLock)
{
return dateFormat.parse(valueString);
}
- catch (Exception e)
- {
- // We'll let this be handled by the outer loop.
- throw e;
- }
- finally
- {
- dateFormatLock.unlock();
- }
}
catch (Exception e)
{
diff --git a/opendj-sdk/opends/src/server/org/opends/server/util/Crypt.java b/opendj-sdk/opends/src/server/org/opends/server/util/Crypt.java
index e34be0a..6751093 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/util/Crypt.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/util/Crypt.java
@@ -33,7 +33,7 @@
/* All Rights Reserved */
package org.opends.server.util;
-import java.util.concurrent.locks.ReentrantLock;
+
/**
* UNIX Crypt cipher, ported from the Sun OpenSolaris project.
@@ -373,7 +373,7 @@
}
}
- private ReentrantLock digestLock = new ReentrantLock();
+ private Object digestLock = new Object();
/**
* Encode the supplied password in unix crypt form with the provided
@@ -387,16 +387,11 @@
* */
public byte[] crypt(byte[] pw, byte[] salt)
{
- digestLock.lock();
int[] r;
- try
+ synchronized (digestLock)
{
r = _crypt(pw, salt);
}
- finally
- {
- digestLock.unlock();
- }
//TODO: crypt always returns same size array? So don't mess
// around calculating the number of zeros at the end.
--
Gitblit v1.10.0