We updated our main server and now we frequently get the following exception:

500 Internal Server Error
java.util.ConcurrentModificationException at
java.util.Hashtable$Enumerator.next(Hashtable.java:931) at
org.mmbase.servlet.MMBaseServlet.incRefCount(MMBaseServlet.java:346) at
org.mmbase.servlet.servscan.service(servscan.java:100) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:336) at
com.evermind[Orion/1.5.2 (build 10460)]._cxb._abe(Unknown Source) at
com.evermind[Orion/1.5.2 (build 10460)]._cxb._uec(Unknown Source) at
com.evermind[Orion/1.5.2 (build 10460)]._io._twc(Unknown Source) at
com.evermind[Orion/1.5.2 (build 10460)]._io._gc(Unknown Source) at
com.evermind[Orion/1.5.2 (build 10460)]._if.run(Unknown Source)

The code where the exception is thrown in incRefCount reads:

for(Iterator i = runningServlets.values().iterator(); i.hasNext();) {
      log.info(i.next());
}

The call to i.next() throws the exception. This code is not synchronized.
I did some digging in CVS and found the old code reads:

for(Enumeration e=runningServlets.elements(); e.hasMoreElements();)
    log.info(e.nextElement());

The Enumeration has changed into an Iterator and I suppose that's the
cause of the problem. I see two options
1: Change it back to Enumeration
2: make the iterator code sync

I prefer the first, cause the second is to expensive in my opinion. For
logging purposes I think it is legal to use an Enumeration that might
be slighly out of date by the time it gets printed. (A concurrent thread
may change the runningServlet HashTable during the print) Using an
Iterator here, seems too expensive to me and causes the mentioned
exception when a concurrent thread modifies the runningServlets
HashTable. Does anyone, maybe especially the developer that changed
the Enemeration into Iterator, oppose reverting back to the old code
using an Enumeration instead of an Iterator?

Wilbert Hengst - [EMAIL PROTECTED]  VPRO-Digitaal - www.vpro.nl
Phone: +31-35-6712728  Fax:+31-35-6712733
Visit: Mediapark, Sumatralaan 45, Hilversum, The Netherlands
Mail: P.O.box 11, 1200 JC Hilversum, The Netherlands


Reply via email to