Author: tolusha
Date: 2010-07-07 01:51:07 -0400 (Wed, 07 Jul 2010)
New Revision: 2747
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
Log:
EXOJCR-840: avoid java.util.ConcurrentModificationException in
LinkedWorkspaceStorageCacheImpl.onSaveItems()
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2010-07-07
05:50:36 UTC (rev 2746)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2010-07-07
05:51:07 UTC (rev 2747)
@@ -563,6 +563,7 @@
*/
class CleanerTask extends WorkerTask
{
+ @Override
public void run()
{
if (currentWorker == null || currentWorker.done)
@@ -582,6 +583,7 @@
*/
class StatisticTask extends WorkerTask
{
+ @Override
public void run()
{
if (currentWorker == null || currentWorker.done)
@@ -1784,33 +1786,41 @@
// delete parent containing child nodes list
nodesCache.remove(parent.getParentIdentifier());
- // traverse itemCache
- Iterator<CacheValue> cacheIterator = cache.values().iterator();
- while (cacheIterator.hasNext())
+ writeLock.lock();
+ try
{
- ItemData cachedItem = cacheIterator.next().getItem();
- if (cachedItem.isNode())
+ // traverse itemCache
+ Iterator<CacheValue> cacheIterator =
cache.values().iterator();
+ while (cacheIterator.hasNext())
{
- if (cachedItem.getQPath().isDescendantOf(parent.getQPath()))
+ ItemData cachedItem = cacheIterator.next().getItem();
+ if (cachedItem.isNode())
{
- cacheIterator.remove();
+ if (cachedItem.getQPath().isDescendantOf(parent.getQPath()))
+ {
+ cacheIterator.remove();
+ }
}
}
- }
- // traverse child node Cache
- Iterator<List<NodeData>> childNodesIterator =
nodesCache.values().iterator();
- while (childNodesIterator.hasNext())
- {
- List<NodeData> list = childNodesIterator.next();
- if (list != null && list.size() > 0)
+ // traverse child node Cache
+ Iterator<List<NodeData>> childNodesIterator =
nodesCache.values().iterator();
+ while (childNodesIterator.hasNext())
{
- if (list.get(0).getQPath().isDescendantOf(parent.getQPath()))
+ List<NodeData> list = childNodesIterator.next();
+ if (list != null && list.size() > 0)
{
- childNodesIterator.remove();
+ if (list.get(0).getQPath().isDescendantOf(parent.getQPath()))
+ {
+ childNodesIterator.remove();
+ }
}
}
}
+ finally
+ {
+ writeLock.unlock();
+ }
}
put(item);
}