High cpu in beanutils WeakHashMap
Environment
- JBoss Enterprise Application Platform (EAP)
- Apache Commons Beanutils
Issue
- We see high CPU usage in several threads accessing a WeakHashMap in
org.apache.commons.beanutils.MethodUtils.getMatchingAccessibleMethod:
"http-mrkcrsbtvlpr01%2F172.25.70.81-8200-206" daemon prio=10 tid=0x00007fbac8275800 nid=0x4865 runnable [0x00007fba97159000]
java.lang.Thread.State: RUNNABLE
at java.util.WeakHashMap.get(WeakHashMap.java:470)
at org.apache.commons.beanutils.MethodUtils.getMatchingAccessibleMethod(MethodUtils.java:530)
at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:209)
at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:217)
at org.apache.commons.digester.Rule.end(Rule.java:253)
Resolution
- Upgrade your commons beanutils library to 1.8.0 or later
Root Cause
- Content from issues.apache.org is not included.BEANUTILS-318
- HashMaps and WeakHashMaps are not thread safe per High CPU due to multiple Java threads accessing HashMap simultaneously
Components
Category
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.