commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject svn commit: r1360140 - /commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java
Date Wed, 11 Jul 2012 12:18:01 GMT
Author: henrib
Date: Wed Jul 11 12:18:00 2012
New Revision: 1360140

URL: http://svn.apache.org/viewvc?rev=1360140&view=rev
Log:
Changed 'version' class member from volatile int to AtomicInteger for clarity 

Modified:
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java?rev=1360140&r1=1360139&r2=1360140&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java
(original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/Uberspect.java
Wed Jul 11 12:18:00 2012
@@ -16,15 +16,6 @@
  */
 package org.apache.commons.jexl3.internal.introspection;
 
-import java.lang.ref.Reference;
-import java.lang.ref.SoftReference;
-import java.lang.reflect.Field;
-
-import java.lang.reflect.Method;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Map;
-
 import org.apache.commons.jexl3.introspection.JexlMethod;
 import org.apache.commons.jexl3.introspection.JexlPropertyGet;
 import org.apache.commons.jexl3.introspection.JexlPropertySet;
@@ -32,6 +23,17 @@ import org.apache.commons.jexl3.introspe
 
 import org.apache.commons.logging.Log;
 
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
+
 /**
  * Implementation of Uberspect to provide the default introspective
  * functionality of JEXL.
@@ -46,10 +48,10 @@ public class Uberspect implements JexlUb
     public static final Object TRY_FAILED = AbstractExecutor.TRY_FAILED;
     /** The logger to use for all warnings & errors. */
     protected final Log rlog;
+    /** The introspector version. */
+    private final AtomicInteger version;
     /** The soft reference to the introspector currently in use. */
     private volatile Reference<Introspector> ref;
-    /** The introspector version. */
-    private volatile int version;
     /** The class loader reference; used to recreate the Introspector when necessary. */
     private volatile Reference<ClassLoader> loader;
 
@@ -61,7 +63,7 @@ public class Uberspect implements JexlUb
         rlog = runtimeLogger;
         ref = new SoftReference<Introspector>(null);
         loader = new SoftReference<ClassLoader>(getClass().getClassLoader());
-        version = 0;
+        version = new AtomicInteger(0);
     }
 
     /**
@@ -80,7 +82,7 @@ public class Uberspect implements JexlUb
                     intro = new Introspector(rlog, loader.get());
                     ref = new SoftReference<Introspector>(intro);
                     loader = new SoftReference<ClassLoader>(intro.getLoader());
-                    version += 1;
+                    version.incrementAndGet();
                 }
             }
         }
@@ -99,15 +101,13 @@ public class Uberspect implements JexlUb
                 ref = new SoftReference<Introspector>(intro);
             }
             loader = new SoftReference<ClassLoader>(intro.getLoader());
-            version += 1;
+            version.incrementAndGet();
         }
     }
 
     @Override
     public int getVersion() {
-        synchronized(this) {
-            return version;
-        }
+        return version.intValue();
     }
 
     /**



Mime
View raw message