From c25504d1f9e2d02afb0f14093a0d16d6b6efb913 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 10 Apr 2015 16:18:30 +0000
Subject: [PATCH] OPENDJ-1878: remove unnecessary entry read locks.

---
 opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java |   59 ++++++++++++++++++-----------------------------------------
 1 files changed, 18 insertions(+), 41 deletions(-)

diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
index ebcca44..37dfbe2 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
@@ -539,28 +539,21 @@
 
     do
     {
-      final Lock lock = LockManager.lockRead(dn);
-      assertNotNull(lock, "could not lock entry " + dn);
-      try
+      final Entry newEntry = DirectoryServer.getEntry(dn);
+      if (newEntry != null)
       {
-        final Entry newEntry = DirectoryServer.getEntry(dn);
-        if (newEntry != null)
+        List<Attribute> tmpAttrList = newEntry.getAttribute(attrTypeStr);
+        if ((tmpAttrList != null) && (!tmpAttrList.isEmpty()))
         {
-          List<Attribute> tmpAttrList = newEntry.getAttribute(attrTypeStr);
-          if ((tmpAttrList != null) && (!tmpAttrList.isEmpty()))
-          {
-            Attribute tmpAttr = tmpAttrList.get(0);
-            found = tmpAttr.contains(ByteString.valueOf(valueString));
-          }
+          Attribute tmpAttr = tmpAttrList.get(0);
+          found = tmpAttr.contains(ByteString.valueOf(valueString));
         }
       }
-      finally
-      {
-        LockManager.unlock(dn, lock);
-      }
 
       if (found != hasAttribute)
+      {
         Thread.sleep(100);
+      }
     } while ((--count > 0) && (found != hasAttribute));
     return found;
   }
@@ -584,19 +577,12 @@
       count--;
     }
 
-    final Lock lock = LockManager.lockRead(dn);
-    assertNotNull(lock, "could not lock entry " + dn);
-    try
+    Entry entry = DirectoryServer.getEntry(dn);
+    if (entry != null)
     {
-      Entry entry = DirectoryServer.getEntry(dn);
-      if (entry != null)
-        return entry.duplicate(true);
-      return null;
+      return entry.duplicate(true);
     }
-    finally
-    {
-      LockManager.unlock(dn, lock);
-    }
+    return null;
   }
 
   /**
@@ -833,25 +819,16 @@
     {
       Thread.sleep(100);
 
-      final Lock lock = LockManager.lockRead(dn);
-      assertNotNull(lock, "could not lock entry " + dn);
-      try
+      Entry newEntry = DirectoryServer.getEntry(dn);
+      if (newEntry != null)
       {
-        Entry newEntry = DirectoryServer.getEntry(dn);
-        if (newEntry != null)
+        Attribute attribute = newEntry.getAttribute("entryuuid").get(0);
+        for (ByteString val : attribute)
         {
-          Attribute attribute = newEntry.getAttribute("entryuuid").get(0);
-          for (ByteString val : attribute)
-          {
-            found = val.toString();
-            break;
-          }
+          found = val.toString();
+          break;
         }
       }
-      finally
-      {
-        LockManager.unlock(dn, lock);
-      }
       count --;
     }
     assertNotNull(found, "Entry: " + dn + " Could not be found.");

--
Gitblit v1.10.0