This is an automated email from the ASF dual-hosted git repository.

jeb pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-query.git


The following commit(s) were added to refs/heads/master by this push:
     new 4b33e7b  SLING-7524 release Set after iteration
4b33e7b is described below

commit 4b33e7ba5fe89234dd7d5d458a63c7c1a9d4c24b
Author: JE Bailey <j...@apache.org>
AuthorDate: Wed Mar 7 08:48:34 2018 -0500

    SLING-7524 release Set after iteration
    
    Release the reference to the Set of seen objects when the iteratation is
    completed.
---
 .../org/apache/sling/query/iterator/UniqueIterator.java    | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/query/iterator/UniqueIterator.java 
b/src/main/java/org/apache/sling/query/iterator/UniqueIterator.java
index e5ad63f..e73149f 100644
--- a/src/main/java/org/apache/sling/query/iterator/UniqueIterator.java
+++ b/src/main/java/org/apache/sling/query/iterator/UniqueIterator.java
@@ -19,16 +19,24 @@
 
 package org.apache.sling.query.iterator;
 
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
 import org.apache.sling.query.api.internal.Option;
 
+/**
+ * Provides an iteration of unique objects. During the iteration process this
+ * iterator maintains a {@link HashSet} of previously seen items that will be
+ * used as filter to prevent duplicates
+ * 
+ * @param <T>
+ */
 public class UniqueIterator<T> extends AbstractIterator<Option<T>> {
 
-       private final Iterator<Option<T>> iterator;
-       
+       private Iterator<Option<T>> iterator;
+
        private Set<T> seen;
 
        public UniqueIterator(Iterator<Option<T>> input) {
@@ -39,6 +47,8 @@ public class UniqueIterator<T> extends 
AbstractIterator<Option<T>> {
        @Override
        protected Option<T> getElement() {
                if (!iterator.hasNext()) {
+                       iterator = Collections.emptyIterator();
+                       seen = null;
                        return null;
                }
                Option<T> candidate = iterator.next();

-- 
To stop receiving notification emails like this one, please contact
j...@apache.org.

Reply via email to