chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1702282 - /chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterator.java
Date Thu, 10 Sep 2015 15:42:52 GMT
Author: fmui
Date: Thu Sep 10 15:42:52 2015
New Revision: 1702282

URL: http://svn.apache.org/r1702282
Log:
OpenCMIS Client: added workaround for repositories that send an empty list and set the hasMoreItems
flag to true (for example in the response of getChildren()) -> prevents NPEs and endless
loops

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterator.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterator.java?rev=1702282&r1=1702281&r2=1702282&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterator.java
Thu Sep 10 15:42:52 2015
@@ -39,11 +39,6 @@ public class CollectionIterator<T> exten
         super(skipCount, pageFetcher);
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#hasNext()
-     */
     @Override
     public boolean hasNext() {
         Page<T> page = getCurrentPage();
@@ -52,7 +47,11 @@ public class CollectionIterator<T> exten
         }
 
         List<T> items = page.getItems();
-        if (items != null && getSkipOffset() < items.size()) {
+        if (items == null || items.isEmpty()) {
+            return false;
+        }
+
+        if (getSkipOffset() < items.size()) {
             return true;
         }
 
@@ -69,11 +68,6 @@ public class CollectionIterator<T> exten
         return (getSkipCount() + getSkipOffset()) < totalItems;
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#next()
-     */
     @Override
     public T next() {
         Page<T> page = getCurrentPage();



Mime
View raw message