jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alex...@apache.org
Subject svn commit: r966624 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
Date Thu, 22 Jul 2010 12:38:52 GMT
Author: alexkli
Date: Thu Jul 22 12:38:52 2010
New Revision: 966624

URL: http://svn.apache.org/viewvc?rev=966624&view=rev
Log:
JCR-2684: Setting Query.setOffset() passed the results total returns negative getSize() instead
of zero

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java?rev=966624&r1=966623&r2=966624&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryResultImpl.java
Thu Jul 22 12:38:52 2010
@@ -455,7 +455,7 @@ public abstract class QueryResultImpl im
             if (total == -1) {
                 return -1;
             }
-            long size = total - offset;
+            long size = offset > total ? 0 : total - offset;
             if (limit >= 0 && size > limit) {
                 return limit;
             } else {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java?rev=966624&r1=966623&r2=966624&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
Thu Jul 22 12:38:52 2010
@@ -138,6 +138,13 @@ public class LimitAndOffsetTest extends 
         assertEquals(2, nodes.getSize());
         assertEquals(3, ((QueryResultImpl) result).getTotalSize());
 
+        // JCR-2684: offset higher than total result => size == 0
+        query.setOffset(10);
+        result = query.execute();
+        nodes = result.getNodes();
+        assertEquals(0, nodes.getSize());
+        assertEquals(3, ((QueryResultImpl) result).getTotalSize());
+
         query.setOffset(1);
         query.setLimit(1);
         result = query.execute();



Mime
View raw message