commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1076450 - /commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterable.java
Date Wed, 02 Mar 2011 23:07:04 GMT
Author: mbenson
Date: Wed Mar  2 23:07:04 2011
New Revision: 1076450

URL: http://svn.apache.org/viewvc?rev=1076450&view=rev
Log:
scale back synchronization

Modified:
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterable.java

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterable.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterable.java?rev=1076450&r1=1076449&r2=1076450&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterable.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterable.java
Wed Mar  2 23:07:04 2011
@@ -80,14 +80,16 @@ public class FilteredIterable<T> impleme
      * @param predicate filter, non-<code>null</code>
      * @return <code>this</code>, fluently
      */
-    public synchronized FilteredIterable<T> retain(UnaryPredicate<? super T>
predicate) {
+    public FilteredIterable<T> retain(UnaryPredicate<? super T> predicate) {
         if (predicate == null) {
             throw new NullPointerException("filtering predicate was null");
         }
-        if (this.predicate == null) {
-            this.predicate = new UnaryAnd<T>();
+        synchronized (this) {
+            if (this.predicate == null) {
+                this.predicate = new UnaryAnd<T>();
+            }
+            this.predicate.and(predicate);
         }
-        this.predicate.and(predicate);
         return this;
     }
 
@@ -138,7 +140,6 @@ public class FilteredIterable<T> impleme
                 }
                 return false;
             }
-
         });
     }
 



Mime
View raw message