ConcurrentModificationException with undertow?

Description

I often hit variations of this when running the lucee docs build on the linux CI server and also locally on windows

 

"ERROR","XNIO-1 task-1","08/30/2019","01:39:13","",";java.util.ConcurrentModificationException;lucee.runtime.exp.NativeException: java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextNode(Unknown Source)
at java.util.HashMap$KeyIterator.next(Unknown Source)

at io.undertow.servlet.util.IteratorEnumeration.nextElement(IteratorEnumeration.java:44)
at lucee.runtime.net.http.HttpUtil.getAttributesAsStruct(HttpUtil.java:63)
at lucee.runtime.net.http.HttpServletRequestDummy.clone(HttpServletRequestDummy.java:700)
at lucee.runtime.thread.ThreadUtil.cloneHttpServletRequest(ThreadUtil.java:124)
at lucee.runtime.thread.ThreadUtil.clonePageContext(ThreadUtil.java:51)
at lucee.runtime.concurrency.UDFCaller2.<init>(UDFCaller2.java:53)
at lucee.runtime.concurrency.UDFCaller2.<init>(UDFCaller2.java:57)
at lucee.runtime.functions.closure.Each._call(Each.java:216)
at lucee.runtime.functions.closure.Each.invoke(Each.java:180)
at lucee.runtime.functions.closure.Each._call(Each.java:92)
at lucee.runtime.functions.closure.Each.call(Each.java:65)

this jumps out as a commandbox problem

at io.undertow.servlet.util.IteratorEnumeration.nextElement(IteratorEnumeration.java:44)

there are a few bugs around from other projects having the same problem

Activity

Show:
Zac Spitzer
November 1, 2019, 11:04 AM

see

Brad Wood
November 1, 2019, 6:06 PM

We’ve put in a ticket to review all the Java library versions in Runwar and see what needs updated. COMMANDBOX-1064

Brad Wood
December 3, 2019, 11:14 PM

The next version of CommandBox will be on the latest version of undertow. Looking at the Lucee source code, there is actually a comment block that says e.nextElement() can throw a ConcurrentModificationException. I’m pretty sure this just boils down to Lucee not synchronizing access to the underlying HTTP attributes when looping over then in two different threads.

The Lucee ticket above is another place inside of Lucee that it iterates over the HTTPServerRequests' attributes. Micha wrapped a synchronized block around it. It looks like he needs to do the same thing here OR find a way to iterate over the request attributes without using a shared Enumeration object. In the case of structClear(), the synchronized block is probably best. In the case of this ticket where Lucee is simply creating a clone of the pageContext, there’s really no reason two threads can’t be doing a read operation at the same time, unless the issue was another thread modifying the request attributes. Either way, I’m 99% sure this ticket belongs in the Lucee tracker. Micha should not be use an Enumeration to iterate as it’s just not thread safe.

 

Zac Spitzer
April 13, 2020, 4:28 PM

I’ve filed a new bug including your above comments

Assignee

Brad Wood

Reporter

Zac Spitzer

Labels

None

Affects versions

Fix versions

Priority

Major
Configure