Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 31786 invoked from network); 2 Feb 2010 23:32:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Feb 2010 23:32:34 -0000 Received: (qmail 16769 invoked by uid 500); 2 Feb 2010 23:32:33 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 16695 invoked by uid 500); 2 Feb 2010 23:32:33 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 16686 invoked by uid 99); 2 Feb 2010 23:32:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Feb 2010 23:32:33 +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.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Feb 2010 23:32:32 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7BCA4238897D; Tue, 2 Feb 2010 23:32:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r905837 - /commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/exception/ExceptionUtils.java Date: Tue, 02 Feb 2010 23:32:12 -0000 To: commits@commons.apache.org From: niallp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100202233212.7BCA4238897D@eris.apache.org> Author: niallp Date: Tue Feb 2 23:32:11 2010 New Revision: 905837 URL: http://svn.apache.org/viewvc?rev=905837&view=rev Log: Port r755391 to 2.x branch - LANG-584 (LANG-369) ExceptionUtils uses mutable lock target Modified: commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/exception/ExceptionUtils.java Modified: commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/exception/ExceptionUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/exception/ExceptionUtils.java?rev=905837&r1=905836&r2=905837&view=diff ============================================================================== --- commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/exception/ExceptionUtils.java (original) +++ commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/exception/ExceptionUtils.java Tue Feb 2 23:32:11 2010 @@ -56,6 +56,9 @@ */ static final String WRAPPED_MARKER = " [wrapped] "; + // Lock object for CAUSE_METHOD_NAMES + private static final Object CAUSE_METHOD_NAMES_LOCK = new Object(); + /** *

The names of methods commonly used to access a wrapped exception.

*/ @@ -123,7 +126,7 @@ if (StringUtils.isNotEmpty(methodName) && !isCauseMethodName(methodName)) { List list = getCauseMethodNameList(); if (list.add(methodName)) { - synchronized(CAUSE_METHOD_NAMES) { + synchronized(CAUSE_METHOD_NAMES_LOCK) { CAUSE_METHOD_NAMES = toArray(list); } } @@ -142,7 +145,7 @@ if (StringUtils.isNotEmpty(methodName)) { List list = getCauseMethodNameList(); if (list.remove(methodName)) { - synchronized(CAUSE_METHOD_NAMES) { + synchronized(CAUSE_METHOD_NAMES_LOCK) { CAUSE_METHOD_NAMES = toArray(list); } } @@ -222,7 +225,7 @@ * @return {@link #CAUSE_METHOD_NAMES} as a List. */ private static ArrayList getCauseMethodNameList() { - synchronized(CAUSE_METHOD_NAMES) { + synchronized(CAUSE_METHOD_NAMES_LOCK) { return new ArrayList(Arrays.asList(CAUSE_METHOD_NAMES)); } } @@ -237,7 +240,7 @@ * @since 2.1 */ public static boolean isCauseMethodName(String methodName) { - synchronized(CAUSE_METHOD_NAMES) { + synchronized(CAUSE_METHOD_NAMES_LOCK) { return ArrayUtils.indexOf(CAUSE_METHOD_NAMES, methodName) >= 0; } } @@ -275,7 +278,7 @@ * @since 1.0 */ public static Throwable getCause(Throwable throwable) { - synchronized(CAUSE_METHOD_NAMES) { + synchronized(CAUSE_METHOD_NAMES_LOCK) { return getCause(throwable, CAUSE_METHOD_NAMES); } } @@ -305,7 +308,7 @@ Throwable cause = getCauseUsingWellKnownTypes(throwable); if (cause == null) { if (methodNames == null) { - synchronized(CAUSE_METHOD_NAMES) { + synchronized(CAUSE_METHOD_NAMES_LOCK) { methodNames = CAUSE_METHOD_NAMES; } } @@ -468,7 +471,7 @@ } Class cls = throwable.getClass(); - synchronized(CAUSE_METHOD_NAMES) { + synchronized(CAUSE_METHOD_NAMES_LOCK) { for (int i = 0, isize = CAUSE_METHOD_NAMES.length; i < isize; i++) { try { Method method = cls.getMethod(CAUSE_METHOD_NAMES[i], null);