Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 84879 invoked from network); 19 Mar 2010 18:54:51 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 19 Mar 2010 18:54:51 -0000 Received: (qmail 56829 invoked by uid 500); 19 Mar 2010 18:54:51 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 56758 invoked by uid 500); 19 Mar 2010 18:54:51 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 56750 invoked by uid 99); 19 Mar 2010 18:54:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Mar 2010 18:54:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Mar 2010 18:54:48 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 2F1CD234C4AE for ; Fri, 19 Mar 2010 18:54:27 +0000 (UTC) Message-ID: <151163885.371001269024867191.JavaMail.jira@brutus.apache.org> Date: Fri, 19 Mar 2010 18:54:27 +0000 (UTC) From: "Andrew Sunde (JIRA)" To: issues@commons.apache.org Subject: [jira] Created: (BEANUTILS-373) CLONE - MethodUtils is not thread safe because WeakFastHashMap which uses WeakHashMap is not thread-safe. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org CLONE - MethodUtils is not thread safe because WeakFastHashMap which uses WeakHashMap is not thread-safe. --------------------------------------------------------------------------------------------------------- Key: BEANUTILS-373 URL: https://issues.apache.org/jira/browse/BEANUTILS-373 Project: Commons BeanUtils Issue Type: Bug Components: Bean / Property Utils Affects Versions: 1.7.0 Environment: Weblogic 9.2 on Linux, but should not be relevant Reporter: Andrew Sunde Assignee: Niall Pemberton Fix For: 1.8.0 The problem lies in the class org.apache.commons.beanutils.MethodUtils. This class is keeping a global cache in a non synchronized WeakHashMap. WeakHashMap is not thread safe and required external synchronization. The lack of synchronization can cause corruption and the WeakHashMap.get() method to go into an infinite loop. Googling "WeakHashMap infinite loop" returns many cases of similar problem with WeakHashMap. The solution is to decorate the WeakHashMap in a synchronized Map as described in this thread: http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg08824.html The modification to make the MethodUtils cache thread safe is a one line change. Before: private static WeakHashMap cache = new WeakHashMap(); After: private static Map cache = Collections.synchronizedMap(new WeakHashMap()); Example of thread dump "ExecuteThread: '0' for queue: 'weblogic.kernel.Default'" id=13 idx=0x3c tid=5905 prio=5 alive, daemon at org/apache/commons/beanutils/MethodUtils$MethodDescriptor.equals(MethodUtils.java:828)[optimized] at java/util/WeakHashMap.eq(WeakHashMap.java:254)[inlined] at java/util/WeakHashMap.get(WeakHashMap.java:345)[optimized] at org/apache/commons/beanutils/MethodUtils.getMatchingAccessibleMethod(MethodUtils.java:530)[optimized] at org/apache/commons/beanutils/MethodUtils.invokeMethod(MethodUtils.java:209)[inlined] :::: "ExecuteThread: '1' for queue: 'weblogic.kernel.Default'" id=14 idx=0x40 tid=5906 prio=5 alive, daemon at org/apache/commons/beanutils/MethodUtils$MethodDescriptor.equals(MethodUtils.java:833)[optimized] at java/util/WeakHashMap.eq(WeakHashMap.java:254)[inlined] at java/util/WeakHashMap.get(WeakHashMap.java:345)[optimized] at org/apache/commons/beanutils/MethodUtils.getMatchingAccessibleMethod(MethodUtils.java:530)[optimized] at org/apache/commons/beanutils/MethodUtils.invokeMethod(MethodUtils.java:209)[inlined] ::: "ExecuteThread: '2' for queue: 'weblogic.kernel.Default'" id=15 idx=0x44 tid=5907 prio=5 alive, daemon at org/apache/commons/beanutils/MethodUtils$MethodDescriptor.equals(MethodUtils.java:833)[optimized] at java/util/WeakHashMap.eq(WeakHashMap.java:254)[inlined] at java/util/WeakHashMap.get(WeakHashMap.java:345)[optimized] at org/apache/commons/beanutils/MethodUtils.getMatchingAccessibleMethod(MethodUtils.java:530)[optimized] at org/apache/commons/beanutils/MethodUtils.invokeMethod(MethodUtils.java:209)[inlined] -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.