Index: src/main/java/org/apache/jackrabbit/core/ItemManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/ItemManager.java (revision 535125)
+++ src/main/java/org/apache/jackrabbit/core/ItemManager.java (working copy)
@@ -120,8 +120,10 @@
/**
* Disposes this ItemManager and frees resources.
*/
- synchronized void dispose() {
- itemCache.clear();
+ void dispose() {
+ synchronized (itemCache) {
+ itemCache.clear();
+ }
}
private NodeDefinition getDefinition(NodeState state)
@@ -596,8 +598,10 @@
* @return the item reference stored in the corresponding cache entry
* or null if there's no corresponding cache entry.
*/
- private synchronized ItemImpl retrieveItem(ItemId id) {
- return (ItemImpl) itemCache.get(id);
+ private ItemImpl retrieveItem(ItemId id) {
+ synchronized (itemCache) {
+ return (ItemImpl) itemCache.get(id);
+ }
}
/**
@@ -606,15 +610,17 @@
*
* @param item the item to cache
*/
- private synchronized void cacheItem(ItemImpl item) {
- ItemId id = item.getId();
- if (itemCache.containsKey(id)) {
- log.warn("overwriting cached item " + id);
+ private void cacheItem(ItemImpl item) {
+ synchronized (itemCache) {
+ ItemId id = item.getId();
+ if (itemCache.containsKey(id)) {
+ log.warn("overwriting cached item " + id);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("caching item " + id);
+ }
+ itemCache.put(id, item);
}
- if (log.isDebugEnabled()) {
- log.debug("caching item " + id);
- }
- itemCache.put(id, item);
}
/**
@@ -622,11 +628,13 @@
*
* @param id id of the item to remove from the cache
*/
- private synchronized void evictItem(ItemId id) {
+ private void evictItem(ItemId id) {
if (log.isDebugEnabled()) {
log.debug("removing item " + id + " from cache");
}
- itemCache.remove(id);
+ synchronized (itemCache) {
+ itemCache.remove(id);
+ }
}
//-------------------------------------------------< misc. helper methods >
@@ -709,21 +717,23 @@
ps.println();
ps.println("Items in cache:");
ps.println();
- Iterator iter = itemCache.keySet().iterator();
- while (iter.hasNext()) {
- ItemId id = (ItemId) iter.next();
- ItemImpl item = (ItemImpl) itemCache.get(id);
- if (item.isNode()) {
- ps.print("Node: ");
- } else {
- ps.print("Property: ");
+ synchronized (itemCache) {
+ Iterator iter = itemCache.keySet().iterator();
+ while (iter.hasNext()) {
+ ItemId id = (ItemId) iter.next();
+ ItemImpl item = (ItemImpl) itemCache.get(id);
+ if (item.isNode()) {
+ ps.print("Node: ");
+ } else {
+ ps.print("Property: ");
+ }
+ if (item.isTransient()) {
+ ps.print("transient ");
+ } else {
+ ps.print(" ");
+ }
+ ps.println(id + "\t" + item.safeGetJCRPath() + " (" + item + ")");
}
- if (item.isTransient()) {
- ps.print("transient ");
- } else {
- ps.print(" ");
- }
- ps.println(id + "\t" + item.safeGetJCRPath() + " (" + item + ")");
}
}