From 6f1406dcda6af294506f212a7f76b813e71521d6 Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Thu, 15 Nov 2007 11:14:04 +0000
Subject: [PATCH] Fix #2597 exceptions after restart of replication server

---
 opends/src/server/org/opends/server/replication/server/ReplicationBackend.java |   36 ++++++++++++++++++++++++------------
 1 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java b/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
index 731fbb1..8be1d81 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
@@ -1142,18 +1142,6 @@
     ArrayList<ReplicationCache> searchContainers =
       new ArrayList<ReplicationCache>();
 
-    if (server==null)
-    {
-      server = retrievesReplicationServer();
-
-      if (server == null)
-      {
-        Message message = ERR_REPLICATIONBACKEND_ENTRY_DOESNT_EXIST.
-        get(String.valueOf(searchBaseDN));
-        throw new DirectoryException(
-          ResultCode.NO_SUCH_OBJECT, message, null, null);
-      }
-    }
     //This check is for GroupManager initialization. It currently doesn't
     //come into play because the replication server variable is null in
     //the check above. But if the order of initialization of the server variable
@@ -1189,6 +1177,30 @@
           ResultCode.NO_SUCH_OBJECT, message, matchedDN, null);
     }
 
+    if (server==null)
+    {
+      server = retrievesReplicationServer();
+
+      if (server == null)
+      {
+        if (baseDNSet.contains(searchBaseDN))
+        {
+          searchOperation.returnEntry(
+              new Entry(searchBaseDN, rootObjectclasses, attributes,
+                  operationalAttributes),
+                  new LinkedList<Control>());
+          return;
+        }
+        else
+        {
+          Message message = ERR_REPLICATIONBACKEND_ENTRY_DOESNT_EXIST.
+          get(String.valueOf(searchBaseDN));
+          throw new DirectoryException(
+              ResultCode.NO_SUCH_OBJECT, message, null, null);
+        }
+      }
+    }
+
     // Walk through all entries and send the ones that match.
     Iterator<ReplicationCache> rcachei = server.getCacheIterator();
     if (rcachei != null)

--
Gitblit v1.10.0