>From 9775ce3154e6f3a8096ec3894e745bbc1f83e23f Mon Sep 17 00:00:00 2001
From: Abhishek Koneru <akoneru@redhat.com>
Date: Mon, 2 Jul 2012 10:40:55 -0400
Subject: [PATCH] Fixes for Comments for Patch 18

---
 .../src/com/netscape/certsrv/request/ARequestNotifier.java      |    6 ++++--
 .../src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java   |    6 ++++--
 .../src/com/netscape/cmscore/dbs/CertificateRepository.java     |    7 ++++---
 base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java     |    7 ++++---
 base/common/src/com/netscape/cmscore/dbs/KeyRepository.java     |    7 ++++---
 base/util/src/netscape/security/provider/MD5.java               |    6 ++++--
 6 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/base/common/src/com/netscape/certsrv/request/ARequestNotifier.java b/base/common/src/com/netscape/certsrv/request/ARequestNotifier.java
index aebb6bf6b500ac1a2bba699a88b05900603f3355..4a6e3260bbd2b8c88e544a6bc7c8a47610279aea 100644
--- a/base/common/src/com/netscape/certsrv/request/ARequestNotifier.java
+++ b/base/common/src/com/netscape/certsrv/request/ARequestNotifier.java
@@ -451,7 +451,7 @@ public class ARequestNotifier implements IRequestNotifier {
      *
      * @param id request request
      */
-    public synchronized void recoverPublishingQueue(String id) {
+    public void recoverPublishingQueue(String id) {
         CMS.debug("recoverPublishingQueue  mRequests.size()=" + mRequests.size() + "(" + mMaxRequests + ")" +
                       " requests by adding request " + id);
         if (mRequests.size() == 0) {
@@ -459,7 +459,9 @@ public class ARequestNotifier implements IRequestNotifier {
             CMS.debug("recoverPublishingQueue  extended buffer to " + mRequests.size() + "(" + mMaxRequests + ")" +
                       " requests by adding request " + id);
             if (morePublishingThreads()) {
-                mSearchForRequests = true;
+                synchronized (this) {
+                    mSearchForRequests = true;
+                }
                 try {
                     Thread notifierThread = new Thread(new RunListeners(this));
                     if (notifierThread != null) {
diff --git a/base/common/src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java b/base/common/src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java
index 577a41256641c24564b9dde03c768883bf157d6b..50b086d9f9e7b3d7795781373cdd5418dd33efc1 100644
--- a/base/common/src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/cert/CrossCertPairSubsystem.java
@@ -96,13 +96,15 @@ public class CrossCertPairSubsystem implements ICrossCertPairSubsystem {
         mId = id;
     }
 
-    public synchronized void init(ISubsystem owner, IConfigStore config)
+    public void init(ISubsystem owner, IConfigStore config)
             throws EBaseException {
         try {
             mConfig = config;
             mLogger = CMS.getLogger();
             mCa = (ICertificateAuthority) CMS.getSubsystem("ca");
-            mPublisherProcessor = mCa.getPublisherProcessor();
+            synchronized (this) {
+                mPublisherProcessor = mCa.getPublisherProcessor();
+            }
 
             // initialize LDAP connection factory
             IConfigStore ldapConfig = mConfig.getSubStore(PROP_LDAP);
diff --git a/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java b/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java
index b5ab354627ce23b12a16f55e505382ba169da935..14e06aeb3e840750ace1c0b73f4c07980fb223dc 100644
--- a/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java
+++ b/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java
@@ -226,12 +226,13 @@ public class CertificateRepository extends Repository
      * 0 - disable
      * >0 - enable
      */
-    public synchronized void setCertStatusUpdateInterval(IRepository requestRepository, int interval,
+    public void setCertStatusUpdateInterval(IRepository requestRepository, int interval,
             boolean listenToCloneModifications) {
 
         CMS.debug("In setCertStatusUpdateInterval " + interval);
-
-        this.requestRepository = requestRepository;
+        synchronized (this) {
+            this.requestRepository = requestRepository;
+        }
 
         // stop running tasks
         if (certStatusUpdateTask != null) {
diff --git a/base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java b/base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java
index 69aaef8907ca4a91605d3bbe5a03a25b55fb01cb..00faa9176637908261f7595b762de9de19923b0a 100644
--- a/base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java
+++ b/base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java
@@ -308,15 +308,16 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
         if (sortKeys == null)
             throw new EBaseException("sort keys cannot be null");
         try {
-            synchronized (mRegistry) {
                 mKeys = new LDAPSortKey[sortKeys.length];
+                String la[] = null;
+                synchronized (this) {
+                   la = mRegistry.getLDAPAttributes(sortKeys);
+                }
 
-                String la[] = mRegistry.getLDAPAttributes(sortKeys);
 
                 for (int j = 0; j < sortKeys.length; j++) {
                     mKeys[j] = new LDAPSortKey(la[j]);
                 }
-            }
         } catch (Exception e) {
 
             /*LogDoc
diff --git a/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java b/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java
index 51537b2cae4e6acd3158cc8ab69b517589dc5d5d..fb3b9b24a40b9ca6ca5e6b4fea5922c01ee6704e 100644
--- a/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java
+++ b/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java
@@ -151,11 +151,12 @@ public class KeyRepository extends Repository implements IKeyRepository {
 
     }
 
-    public synchronized void setKeyStatusUpdateInterval(IRepository requestRepo, int interval) {
+    public void setKeyStatusUpdateInterval(IRepository requestRepo, int interval) {
 
         CMS.debug("In setKeyStatusUpdateInterval " + interval);
-
-        this.requestRepository = requestRepo;
+        synchronized (this) {
+            this.requestRepository = requestRepo;
+        }
 
         // stop running task
         if (mKeyStatusUpdateTask != null) {
diff --git a/base/util/src/netscape/security/provider/MD5.java b/base/util/src/netscape/security/provider/MD5.java
index 98405e51e6d3bce82805daba0843389f787667db..85f9da12d361c8d703df9df71a98669a84859953 100644
--- a/base/util/src/netscape/security/provider/MD5.java
+++ b/base/util/src/netscape/security/provider/MD5.java
@@ -227,10 +227,12 @@ public final class MD5 extends MessageDigestSpi implements Cloneable {
      * to 0. Given this implementation you are constrained to counting
      * 2^64 bits.
      */
-    public synchronized void init() {
+    public void init() {
         state = new int[4];
         transformBuffer = new int[16];
-        buffer = new byte[64];
+        synchronized (this) {
+            buffer = new byte[64];
+        }
         digestBits = new byte[16];
         count = 0;
         // Load magic initialization constants.
-- 
1.7.10.2

