commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
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 GMT
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();
+    
     /**
      * <p>The names of methods commonly used to access a wrapped exception.</p>
      */
@@ -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);



Mime
View raw message