[ 
https://issues.apache.org/jira/browse/BEANUTILS-509?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16633945#comment-16633945
 ] 

Akshay Gehi commented on BEANUTILS-509:
---------------------------------------

The above issues are similar to this issue. WrapDynaClass uses 
CLASSLOADER_CACHE which uses WeakHaspMap in an incorrect way. WeakHashMap is 
not thread safe therefore for WrapDynaClass to be threadsafe, it should use a 
synchorized access to WeakHashMap as the following 

 
{code:java}
private static final ContextClassLoaderLocal<Map<CacheKey, WrapDynaClass>> 
CLASSLOADER_CACHE =
new ContextClassLoaderLocal<Map<CacheKey, WrapDynaClass>>() {
@Override
protected Map<CacheKey, WrapDynaClass> initialValue() {
return Collections.synchronizedMap(new WeakHashMap<CacheKey, WrapDynaClass>());
}
};
{code}

> WeakHashmap enters into infinite loop in WrapDynaClass.java
> -----------------------------------------------------------
>
>                 Key: BEANUTILS-509
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-509
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: DynaBean
>    Affects Versions: 1.8.2
>            Reporter: sunil
>            Priority: Major
>         Attachments: console.log.backup
>
>
> We noticed that our application was using too much of CPU , all the 6 cores 
> were used. 
> On capturing the thread dump we saw that large number of threads were in the 
> running state and in :
> at java.util.WeakHashMap.get(WeakHashMap.java:403)
>  at 
> org.apache.commons.beanutils.WrapDynaClass.createDynaClass(WrapDynaClass.java:425)
>  
> So we are suspecting that the thread has entered into indefinite while loop 
> and hogging all the CPU resources.
> I have attached the thread dump for reference.  
>  
> what is the solution for this issue?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to