[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-330) NegativeArraySizeException if you use FullTextQuery.setMaxResults(Integer.MAX_VALUE)

Hardy Ferentschik (JIRA) noreply at atlassian.com
Wed Apr 29 14:56:17 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33047#action_33047 ] 

Hardy Ferentschik commented on HSEARCH-330:
-------------------------------------------

Well, one way of fixing this is to make sure that the max value is always less than Integer.MAX_VALUE. we could change calculateTopDocsRetrievalSize() to

	private Integer calculateTopDocsRetrievalSize() {
		if ( maxResults == null ) {
			return null;
		}
		else {
			long tmpMaxResult = first() + maxResults;
			if ( tmpMaxResult >= Integer.MAX_VALUE ) {
				return Integer.MAX_VALUE - 1;
			}
			else {
				return (int) tmpMaxResult;
			}
		}
	}

However, on many systems this will lead to a OutOfMemoryError - Requested array size exceeds VM limit.
Lucene tries to allocate an Object array of the the maxResult size which will fail on many Systems. I think the above code is correct though, but I cannot check in a test case since once the 
NegativeArraySizeException is fixed a OutOfMemoryError will occur.



> NegativeArraySizeException if you use FullTextQuery.setMaxResults(Integer.MAX_VALUE)
> ------------------------------------------------------------------------------------
>
>                 Key: HSEARCH-330
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-330
>             Project: Hibernate Search
>          Issue Type: Bug
>            Reporter: Hardy Ferentschik
>            Assignee: Hardy Ferentschik
>             Fix For: 3.1.1
>
>
> Seems to be a Lucene bug, but maybe we should add a work around?
> http://forum.hibernate.org/viewtopic.php?p=2401667

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list