Non-thread-safe usage of HashMap in LazyActionHandlerValidatorRegistryImpl can cause 100% CPU usage

116 views
Skip to first unread message

Lalit Mishra

unread,
Dec 17, 2012, 2:32:09 AM12/17/12
to gwt-pl...@googlegroups.com
Recently we faced high CPU utilization by tomcat process running a GWTP and Spring based web-application. The thread dump shows several threads executing which stack-traces similar to following -

"http-443-2" daemon prio=10 tid=0x09d47000 nid=0x159e runnable [0x8cfd3000]
   java.lang.Thread.State: RUNNABLE
        at java.util.HashMap.get(Unknown Source)
        at com.gwtplatform.dispatch.server.spring.actionhandlervalidator.LazyActionHandlerValidatorRegistryImpl.findActionHandlerValidator(LazyActionHandlerValidatorRegistryImpl.java:68)
        at com.gwtplatform.dispatch.server.AbstractDispatchImpl.findHandler(AbstractDispatchImpl.java:196)
        at com.gwtplatform.dispatch.server.AbstractDispatchImpl.doExecute(AbstractDispatchImpl.java:147)
        at com.gwtplatform.dispatch.server.AbstractDispatchImpl.execute(AbstractDispatchImpl.java:111)
        at com.gwtplatform.dispatch.server.AbstractDispatchServiceImpl.execute(AbstractDispatchServiceImpl.java:81)

It seems that concurrent modifications to the maps used in this class may result in corrupted indexes in hashmap. For immediate fix, how would we be able to override the ActionValidatorHandlerRegistry being used?

Christian Goudreau

unread,
Dec 17, 2012, 9:23:43 AM12/17/12
to gwt-pl...@googlegroups.com
You can directly change the code in the source and contribute a patch. We're not big spring users and every bit of help is welcome in that part of the code! :D


--
 
 



--
Christian Goudreau

Lalit Mishra

unread,
Jan 30, 2013, 6:43:56 AM1/30/13
to gwt-pl...@googlegroups.com
Hello Christian,

Please find attached patch that just replaces, HashMap with ConcurrentHashMap in LazyActionHandlerValidatorRegistryImpl. I've not been able to come up with a test case which would demonstrate effectiveness of the fix, as the problem itself manifests under race conditions.

Thanks,
Lalit Mishra
gwt-p-hashmap.patch

Christian Goudreau

unread,
Feb 9, 2013, 12:02:12 PM2/9/13
to gwt-pl...@googlegroups.com
Thanks, would it be too much to ask to open a pull request directly on github? :D 


--
You received this message because you are subscribed to the Google Groups "GWTP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gwt-platform...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Christian Goudreau

Christian Goudreau

unread,
Feb 9, 2013, 12:02:30 PM2/9/13
to gwt-pl...@googlegroups.com
So that you're awarded the contribution instead of me :D
--
Christian Goudreau

Lalit Mishra

unread,
Feb 10, 2013, 1:43:18 AM2/10/13
to gwt-pl...@googlegroups.com
Will do that. Thanks :)
Reply all
Reply to author
Forward
0 new messages