mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

neil_a_wilson
12.03.2007 47be44124da7f6ad42bed03a24701ca07c00918d
Make a couple of changes to help improve server performance:

- Update the server code to replace simple uses of ReentrantLock involving
{lock, doSomething, unlock} in the same method to use the synchronized
keyword instead of a ReentrantLock object. Using the synchronized keyword is
actually a little faster, and also simplifies the code since it's no longer
necessary to use a finally block to ensure that the lock is released.

- Update the AsynchronousTextWriter to use the LinkedBlockingQueue.drainTo()
method to attempt to get multiple messages at once, rather than always using
poll() to get one message at a time.
23 files modified
1330 ■■■■ changed files
opends/src/server/org/opends/server/config/ConfigEntry.java 43 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/LockFileManager.java 31 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/CRAMMD5SASLMechanismHandler.java 22 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/ConfigFileHandler.java 30 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/CryptPasswordStorageScheme.java 10 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/DigestMD5SASLMechanismHandler.java 43 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/MD5PasswordStorageScheme.java 26 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/RandomPasswordGenerator.java 34 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/SHA1PasswordStorageScheme.java 26 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/SaltedMD5PasswordStorageScheme.java 41 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/SaltedSHA1PasswordStorageScheme.java 41 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/SaltedSHA256PasswordStorageScheme.java 41 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/SaltedSHA384PasswordStorageScheme.java 41 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/SaltedSHA512PasswordStorageScheme.java 41 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/TraditionalWorkQueue.java 51 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/loggers/AsyncronousTextWriter.java 35 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java 54 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/protocols/ldap/LDAPStatistics.java 509 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/schema/GeneralizedTimeEqualityMatchingRule.java 46 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/schema/GeneralizedTimeOrderingMatchingRule.java 53 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/schema/GeneralizedTimeSyntax.java 51 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/schema/UTCTimeSyntax.java 50 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/Crypt.java 11 ●●●● patch | view | raw | blame | history
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,8 +383,8 @@
  public ConfigEntry removeChild(DN childDN)
         throws ConfigException
  {
    entryLock.lock();
    synchronized (entryLock)
    {
    try
    {
      ConfigEntry childEntry = children.get(childDN);
@@ -443,9 +421,6 @@
              stackTraceToSingleLineString(e));
      throw new ConfigException(message, e);
    }
    finally
    {
      entryLock.unlock();
    }
  }
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();
    }
  }
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();
    }
  }
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();
    }
  }
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();
    }
  }
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();
    }
    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();
    }
  }
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,8 +148,8 @@
  {
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      digestBytes = messageDigest.digest(plaintext.value());
@@ -167,9 +166,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    return ByteStringFactory.create(Base64.encode(digestBytes));
@@ -191,8 +187,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      digestBytes = messageDigest.digest(plaintext.value());
@@ -209,9 +205,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    buffer.append(Base64.encode(digestBytes));
@@ -231,8 +224,8 @@
  {
    byte[] userPWDigestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      userPWDigestBytes = messageDigest.digest(plaintextPassword.value());
@@ -246,9 +239,6 @@
      return false;
    }
    finally
    {
      digestLock.unlock();
    }
    byte[] storedPWDigestBytes;
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();
      }
    }
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,8 +147,8 @@
  {
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      digestBytes = messageDigest.digest(plaintext.value());
@@ -166,9 +165,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    return ByteStringFactory.create(Base64.encode(digestBytes));
@@ -190,8 +186,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      digestBytes = messageDigest.digest(plaintext.value());
@@ -208,9 +204,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    buffer.append(Base64.encode(digestBytes));
@@ -229,8 +222,8 @@
  {
    byte[] userPWDigestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      userPWDigestBytes = messageDigest.digest(plaintextPassword.value());
@@ -244,9 +237,6 @@
      return false;
    }
    finally
    {
      digestLock.unlock();
    }
    byte[] storedPWDigestBytes;
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,8 +170,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -195,9 +194,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    // Append the salt to the hashed value and base64-the whole thing.
@@ -232,8 +228,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -256,9 +252,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    // Append the salt to the hashed value and base64-the whole thing.
@@ -317,8 +310,8 @@
    byte[] userDigestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      userDigestBytes = messageDigest.digest(plainPlusSalt);
@@ -332,9 +325,6 @@
      return false;
    }
    finally
    {
      digestLock.unlock();
    }
    return Arrays.equals(digestBytes, userDigestBytes);
@@ -380,8 +370,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -404,9 +394,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
@@ -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();
    }
  }
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,8 +168,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -193,9 +192,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    // Append the salt to the hashed value and base64-the whole thing.
@@ -230,8 +226,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -254,9 +250,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    // Append the salt to the hashed value and base64-the whole thing.
@@ -315,8 +308,8 @@
    byte[] userDigestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      userDigestBytes = messageDigest.digest(plainPlusSalt);
@@ -330,9 +323,6 @@
      return false;
    }
    finally
    {
      digestLock.unlock();
    }
    return Arrays.equals(digestBytes, userDigestBytes);
@@ -378,8 +368,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -402,9 +392,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
@@ -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();
    }
  }
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,8 +171,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -196,9 +195,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    // Append the salt to the hashed value and base64-the whole thing.
@@ -233,8 +229,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -257,9 +253,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    // Append the salt to the hashed value and base64-the whole thing.
@@ -318,8 +311,8 @@
    byte[] userDigestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      userDigestBytes = messageDigest.digest(plainPlusSalt);
@@ -333,9 +326,6 @@
      return false;
    }
    finally
    {
      digestLock.unlock();
    }
    return Arrays.equals(digestBytes, userDigestBytes);
@@ -381,8 +371,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -405,9 +395,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
@@ -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();
    }
  }
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,8 +171,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -196,9 +195,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    // Append the salt to the hashed value and base64-the whole thing.
@@ -233,8 +229,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -257,9 +253,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    // Append the salt to the hashed value and base64-the whole thing.
@@ -318,8 +311,8 @@
    byte[] userDigestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      userDigestBytes = messageDigest.digest(plainPlusSalt);
@@ -333,9 +326,6 @@
      return false;
    }
    finally
    {
      digestLock.unlock();
    }
    return Arrays.equals(digestBytes, userDigestBytes);
@@ -381,8 +371,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -405,9 +395,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
@@ -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();
    }
  }
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,8 +170,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -195,9 +194,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    // Append the salt to the hashed value and base64-the whole thing.
@@ -232,8 +228,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -256,9 +252,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
    // Append the salt to the hashed value and base64-the whole thing.
@@ -317,8 +310,8 @@
    byte[] userDigestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      userDigestBytes = messageDigest.digest(plainPlusSalt);
@@ -332,9 +325,6 @@
      return false;
    }
    finally
    {
      digestLock.unlock();
    }
    return Arrays.equals(digestBytes, userDigestBytes);
@@ -380,8 +370,8 @@
    byte[] digestBytes;
    digestLock.lock();
    synchronized (digestLock)
    {
    try
    {
      // Generate the salt and put in the plain+salt array.
@@ -404,9 +394,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      digestLock.unlock();
    }
@@ -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();
    }
  }
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,8 +353,8 @@
    // so, then return null and the thread will exit.
    if (killThreads)
    {
      queueLock.lock();
      synchronized (queueLock)
      {
      try
      {
        int currentThreads = workerThreads.size();
@@ -382,9 +381,6 @@
          TRACER.debugCaught(DebugLogLevel.ERROR, e);
        }
      }
      finally
      {
        queueLock.unlock();
      }
    }
@@ -415,8 +411,8 @@
          }
          else if (killThreads)
          {
            queueLock.lock();
            synchronized (queueLock)
            {
            try
            {
              int currentThreads = workerThreads.size();
@@ -443,9 +439,6 @@
                TRACER.debugCaught(DebugLogLevel.ERROR, e);
              }
            }
            finally
            {
              queueLock.unlock();
            }
          }
        }
@@ -581,8 +574,8 @@
    int currentThreads = workerThreads.size();
    if (newNumThreads != currentThreads)
    {
      queueLock.lock();
      synchronized (queueLock)
      {
      try
      {
        int threadsToAdd = newNumThreads - currentThreads;
@@ -612,9 +605,6 @@
          TRACER.debugCaught(DebugLogLevel.ERROR, e);
        }
      }
      finally
      {
        queueLock.unlock();
      }
    }
@@ -626,8 +616,8 @@
    // checks will be against the new queue.
    if (newMaxCapacity != maxCapacity)
    {
      queueLock.lock();
      synchronized (queueLock)
      {
      try
      {
        LinkedBlockingQueue<AbstractOperation> newOpQueue;
@@ -685,9 +675,6 @@
          TRACER.debugCaught(DebugLogLevel.ERROR, e);
        }
      }
      finally
      {
        queueLock.unlock();
      }
    }
@@ -708,9 +695,7 @@
      return false;
    }
    queueLock.lock();
    try
    synchronized (queueLock)
    {
      for (TraditionalWorkerThread t : workerThreads)
      {
@@ -722,10 +707,6 @@
      return true;
    }
    finally
    {
      queueLock.unlock();
    }
  }
}
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,10 +107,15 @@
     */
    public void run()
    {
      ArrayList<String> drainList = new ArrayList<String>(capacity);
      String message = null;
      while (!stopRequested.get() || !queue.isEmpty()) {
        try
        {
          queue.drainTo(drainList, capacity);
          if (drainList.isEmpty())
          {
          message = queue.poll(10, TimeUnit.SECONDS);
          if(message != null)
          {
@@ -119,6 +132,20 @@
            }
          }
        }
          else
          {
            for (String record : drainList)
            {
              writer.writeRecord(record);
            }
            drainList.clear();
            if (autoFlush)
            {
              flush();
            }
          }
        }
        catch (InterruptedException ex) {
          // Ignore. We'll rerun the loop
          // and presumably fall out.
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,8 +873,8 @@
    // 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();
    synchronized (transmitLock)
    {
    try
    {
      try
@@ -924,9 +923,6 @@
      disconnect(DisconnectReason.SERVER_ERROR, true, null);
      return;
    }
    finally
    {
      transmitLock.unlock();
    }
  }
@@ -974,8 +970,8 @@
    // 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();
    synchronized (opsInProgressLock)
    {
    try
    {
      disconnectRequested = true;
@@ -987,9 +983,6 @@
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
    }
    finally
    {
      opsInProgressLock.unlock();
    }
    cancelAllOperations(new CancelRequest(true, message));
@@ -1174,8 +1167,8 @@
    // 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();
    synchronized (opsInProgressLock)
    {
    try
    {
      // If we're already in the process of disconnecting the client, then
@@ -1183,16 +1176,18 @@
      if (disconnectRequested)
      {
        Message message = WARN_LDAP_CLIENT_DISCONNECT_IN_PROGRESS.get();
        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
          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.
        // 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);
          Message message =
               WARN_LDAP_CLIENT_DUPLICATE_MESSAGE_ID.get(messageID);
        throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message);
      }
@@ -1229,9 +1224,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      opsInProgressLock.unlock();
    }
  }
@@ -1322,8 +1314,8 @@
  public void cancelAllOperations(CancelRequest cancelRequest)
  {
    // Make sure that no one can add any new operations.
    opsInProgressLock.lock();
    synchronized (opsInProgressLock)
    {
    try
    {
      for (AbstractOperation o : operationsInProgress.values())
@@ -1366,9 +1358,6 @@
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
    }
    finally
    {
      opsInProgressLock.unlock();
    }
  }
@@ -1387,8 +1376,8 @@
                                        int messageID)
  {
    // Make sure that no one can add any new operations.
    opsInProgressLock.lock();
    synchronized (opsInProgressLock)
    {
    try
    {
      for (int msgID : operationsInProgress.keySet())
@@ -1436,9 +1425,6 @@
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
    }
    finally
    {
      opsInProgressLock.unlock();
    }
  }
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,65 +460,10 @@
              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();
    }
  }
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();
  }
  /**
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()
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));
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)
    {
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.