From 0bc01c5f010215ce449fffad038bd2fc1a9046c1 Mon Sep 17 00:00:00 2001
From: abobrov <abobrov@localhost>
Date: Tue, 21 Aug 2007 21:56:56 +0000
Subject: [PATCH] - fix map inconsistency bug in clearBackend method. - sanitize backend handling in clearSubtree method.
---
opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
index c33e8eb..380c4f5 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
@@ -860,14 +860,20 @@
Map<Long,DN> backendEntriesMap = backendMap.get(backend);
try {
+ if (backendEntriesMap == null) {
+ // No entries were in the cache for this backend,
+ // so we can return without doing anything.
+ return;
+ }
int entriesExamined = 0;
- Set<Long> entriesSet = backendEntriesMap.keySet();
- Iterator<Long> backendEntriesIterator = entriesSet.iterator();
+ Iterator<Long> backendEntriesIterator =
+ backendEntriesMap.keySet().iterator();
while (backendEntriesIterator.hasNext()) {
- long entryID = backendEntriesIterator.next();
+ Long entryID = backendEntriesIterator.next();
DN entryDN = backendEntriesMap.get(entryID);
entryCacheDB.delete(null,
new DatabaseEntry(entryDN.toNormalizedString().getBytes("UTF-8")));
+ backendEntriesIterator.remove();
dnMap.remove(entryDN);
// This can take a while, so we'll periodically release and re-acquire
@@ -881,12 +887,13 @@
}
}
+ // This backend is empty now, remove it from the backend map.
+ backendMap.remove(backend);
} catch (Exception e) {
if (debugEnabled()) {
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
} finally {
- backendMap.remove(backend);
cacheWriteLock.unlock();
}
}
@@ -980,6 +987,12 @@
}
}
+ // If this backend becomes empty now
+ // remove it from the backend map.
+ if (map.isEmpty()) {
+ backendMap.remove(backend);
+ }
+
// See if the backend has any subordinate backends. If so, then process
// them recursively.
for (Backend subBackend : backend.getSubordinateBackends())
--
Gitblit v1.10.0