concurrentmodification - Intermittent ConcurrentModificationException when iterating over Grails parameter map -


i see concurrentmodificationexception below in grails application's log in ci. think happens when app under lot of load (we fire 8 concurrent geb test shards @ same tomcat instance).

2015-06-14 13:44:16,702 [http-bio-8080-exec-53] error errors.grailsexceptionresolver  - concurrentmodificationexception occurred when processing request: [post] /myapp/task/getschedules stacktrace follows: java.util.concurrentmodificationexception     @ java.util.linkedhashmap$linkedhashiterator.nextentry(linkedhashmap.java:394)     @ java.util.linkedhashmap$entryiterator.next(linkedhashmap.java:413)     @ java.util.linkedhashmap$entryiterator.next(linkedhashmap.java:412)     @ com.myapp.controller.controllersearchservice.getmostrecentprefixedparams(controllersearchservice.groovy:83)     @ com.myapp.controller.controllersearchservice.getmostrecentfilterparams(controllersearchservice.groovy:65)     @ com.myapp.controller.controllersearchservice.advancedsearch(controllersearchservice.groovy:239)     @ com.myapp.aspect.servicemethodtimingaspect.traceservicemethodcall(servicemethodtimingaspect.java:20)     @ grailsmelodygrailsplugin$_closure4_closure16_closure17.docall(grailsmelodygrailsplugin.groovy:184)     @ com.myapp.task.taskcontroller.getschedules(taskcontroller.groovy:287)     @ grails.plugin.cache.web.filter.pagefragmentcachingfilter.dofilter(pagefragmentcachingfilter.java:195)     @ grails.plugin.cache.web.filter.abstractfilter.dofilter(abstractfilter.java:63)     @ net.bull.javamelody.jspwrapper.invoke(jspwrapper.java:150)     @ net.bull.javamelody.jdbcwrapper$delegatinginvocationhandler.invoke(jdbcwrapper.java:285)     @ net.bull.javamelody.monitoringfilter.dofilter(monitoringfilter.java:198)     @ net.bull.javamelody.monitoringfilter.dofilter(monitoringfilter.java:176)     @ grails.plugin.springsecurity.web.filter.grailsanonymousauthenticationfilter.dofilter(grailsanonymousauthenticationfilter.java:53)     @ com.myapp.organisation.security.restauthenticationfilter.dofilter(restauthenticationfilter.groovy:160)     @ grails.plugin.springsecurity.web.authentication.requestholderauthenticationfilter.dofilter(requestholderauthenticationfilter.java:49)     @ grails.plugin.springsecurity.web.authentication.logout.mutablelogoutfilter.dofilter(mutablelogoutfilter.java:82)     @ com.odobo.grails.plugin.springsecurity.rest.restlogoutfilter.dofilter(restlogoutfilter.groovy:63)     @ org.grails.jaxrs.web.jaxrsfilter.dofilterinternal(jaxrsfilter.java:46)     @ com.brandseye.cors.corsfilter.dofilter(corsfilter.java:82)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615)     @ java.lang.thread.run(thread.java:745) 

the code in getmostrecentprefixedparams method looks this:

private def getmostrecentprefixedparams(params, session, prefix, sessionparamname) {     synchronized (params) {         (string key : params) {     // line 83 - exception happens here             if (key.startswith(prefix)) {                 if (session != null) {                     cleartags(params)                 }                 return params             }         }     }      if (session == null) {         return params     }      return session."${sessionparamname}" == null ? params : session."${sessionparamname}" } 

i added synchronized block in attempt stop happening, else going on.

the params argument passed getmostrecentprefixedparams method comes controller (the implicit params controller property) - far i'm aware, single request thread should have access map during entire request/response cycle, if wasn't case , thread somehow had access map, have thought synchronized block have prevented concurrentmodificationexception.

we're using grails 2.3.7.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -