ConcurrentModificationException

10 views
Skip to first unread message

mschipperheyn

unread,
Apr 11, 2012, 12:19:17 PM4/11/12
to bobo-...@googlegroups.com
Hi,

I'm storing FacetHandlers in a local cache for reuse across requests. Also, I'm storing the BoboIndexReader in a cache that I temporarily refresh.

I'm sometimes seeing 

[code]
java.util.ConcurrentModificationException
        at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
        at java.util.AbstractList$Itr.next(AbstractList.java:343)
[/code]

occur in the log when I'm looping over a list of facethandlers I retrieved from the cache. This doesn't happen often. I'm just wondering when this might occur and how to avoid this?

[code]
for (FacetHandler<?> fh : handlerList) {//BOOM
[...]
}
[/code]

Could this be a problem related to the refreshing of the BoboIndexReader?

My code for this is 

[code]
@Override
public void refreshBoboIndexReader(Class<?> clazz, boolean reopen) {
try {
if (reopen) {
setBoboIndexReader(clazz, getBoboReader(clazz));
}
} catch (IOException io) {
log.error("Error creating indexReader", io);
}
}
protected void setBoboIndexReader(Class<?> clazz, BoboIndexReader breader)
throws IOException {
MyDaoHibernate.writeLock.lock();
try {
if (boboReaders.containsKey(clazz))
boboReaders.get(clazz).close();
boboReaders.put(clazz, breader);
} finally {
MyDaoHibernate.writeLock.unlock();
}
}
protected BoboIndexReader getBoboReader(final Class<?> clazz)
throws IOException {
TransactionTemplate transTemplate = new TransactionTemplate(
transactionManager);

IndexReader i = transTemplate
.execute(new TransactionCallback<IndexReader>() {

@Override
public IndexReader doInTransaction(
TransactionStatus status) {
FullTextSession fts = Search
.getFullTextSession(getSessionFactory()
.getCurrentSession());
MutableSearchFactory factory = (MutableSearchFactory) fts.getSearchFactory();
DirectoryBasedIndexManager mgr = (DirectoryBasedIndexManager) factory.getAllIndexesManager().getIndexManager(clazz.getCanonicalName());
try{

return IndexReader.open(mgr.getDirectoryProvider().getDirectory(), true);
}catch(IOException io){
log.error("Error opening indexreader for Bobo", io);
}
return null;
}
});
return BoboIndexReader.getInstance(
i,
sfFactory.getUnfilteredList(), null);
}

[/code]

Kind regards,
Marc

mschipperheyn

unread,
Apr 16, 2012, 7:53:02 AM4/16/12
to bobo-browse
Anyone? This is pretty serious for me and I'm seeing it more often
now.

mschipperheyn

unread,
Apr 17, 2012, 4:38:54 PM4/17/12
to bobo-browse
HELP!

mschipperheyn

unread,
Apr 17, 2012, 5:13:25 PM4/17/12
to bobo-browse
Ok, fixed. This didn't have anything to do with Bobo. I was adding a
facethandler to a cached list of facethandlers conditionally. This
generated the concurrentmod exception
Reply all
Reply to author
Forward
0 new messages