Author: hardy.ferentschik
Date: 2009-05-12 11:25:27 -0400 (Tue, 12 May 2009)
New Revision: 16553
Modified:
search/branches/Branch_3_1/src/java/org/hibernate/search/query/FullTextQueryImpl.java
Log:
Backported HSEARCH-330
Modified:
search/branches/Branch_3_1/src/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
---
search/branches/Branch_3_1/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2009-05-12
15:21:13 UTC (rev 16552)
+++
search/branches/Branch_3_1/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2009-05-12
15:25:27 UTC (rev 16553)
@@ -359,15 +359,22 @@
/**
* @return Calculates the number of <code>TopDocs</code> which should be
retrieved as part of the query. If Hibernate's
- * pagination parameters are set returned value is <code>first +
maxResults</code>. Otherwise <code>null</code> is
- * returned.
+ * pagination parameters are set returned value is <code>first +
maxResults</code>. Otherwise <code>null</code> is
+ * returned.
*/
private Integer calculateTopDocsRetrievalSize() {
if ( maxResults == null ) {
return null;
}
else {
- return first() + maxResults;
+ long tmpMaxResult = (long) first() + maxResults;
+ if ( tmpMaxResult >= Integer.MAX_VALUE ) {
+ // don't return just Integer.MAX_VALUE due to a bug in Lucene - see HSEARCH-330
+ return Integer.MAX_VALUE - 1;
+ }
+ else {
+ return (int) tmpMaxResult;
+ }
}
}