I just got a ConcurrentModificationException from calling into htmlunit code. Here is the (truncated) stacktrace:
java.util.ConcurrentModificationException at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:394) at java.util.LinkedHashMap$EntryIterator.next(LinkedHashMap.java:413) at java.util.LinkedHashMap$EntryIterator.next(LinkedHashMap.java:412) at com.gargoylesoftware.htmlunit.html.DomElement.printOpeningTagContentAsXml(DomElement.java:144) at com.gargoylesoftware.htmlunit.html.HtmlElement.toString(HtmlElement.java:614) at java.lang.String.valueOf(String.java:2847) at java.lang.StringBuilder.append(StringBuilder.java:128) at com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement.toString(HTMLElement.java:1749) at java.lang.String.valueOf(String.java:2847) at java.lang.StringBuilder.append(StringBuilder.java:128) at com.gargoylesoftware.htmlunit.javascript.host.Event.toString(Event.java:686) at java.lang.String.valueOf(String.java:2847) at java.lang.StringBuilder.append(StringBuilder.java:128) at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:864) at com.gargoylesoftware.htmlunit.html.HtmlElement.type(HtmlElement.java:482) at com.gargoylesoftware.htmlunit.html.HtmlElement.type(HtmlElement.java:431) at com.gargoylesoftware.htmlunit.html.HtmlElement.type(HtmlElement.java:400) at org.openqa.selenium.htmlunit.HtmlUnitKeyboard.sendKeys(HtmlUnitKeyboard.java:70) at org.openqa.selenium.htmlunit.HtmlUnitWebElement.sendKeys(HtmlUnitWebElement.java:343)
HtmlUnitWebElement.sendkeys is where my user code called into htmlunit. Running the same test again did not reproduce the error. The gradle dependencies we are using are: 'org.seleniumhq.selenium:selenium-java:2.33.0', 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.33.0'.
I wonder if this is also the cause of jwebunit bug 114.
Hi Philip,
usually this happens, if there is some javascript that modifies the dom tree in parallel to you foreground task.
Did a quick look at the code and this special case seems to be triggered by some debug code (HTMLElement.toString). So for your case changing the log level to info/warn for HTMLElement might help.
Will think about this, maybe we can change at least the toString code in a way, that it will not influence the normal program flow.
There is a 'fix' in SVN. At least the toString method now ignores the CME.
Thanks for reporting
Last edit: RBRi 2014-09-15
Sorry but i had to revert the fix because it was only a hack.