-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: java.lang.NegativeSizeArrayException.
PostPosted: Wed Dec 17, 2008 1:21 am 
Newbie

Joined: Tue Dec 16, 2008 11:06 pm
Posts: 3
Hi,

First up, I'm not 100% sure whether this question should be posted in this forum, or the lucene forum. However, given I'm experiencing a problem that happens to coincide with an upgrade to Hibernate search 3.1.0.GA, I'll post here and take advice as to whether I should repost on lucene. Secondly, thanks for Hibernate search! It's made our life much easier and allowed us to deliver some powerful functionality very quickly and with little code.

Now... I've recently upgraded to hibernate search 3.1.0.GA. I have some unit tests that are now failing with a java.lang.NegativeSizeArrayException (Stack trace below). My unit tests create a FullTextQuery and invoke the setMaxResults(Integer) method passing in Integer.MAX_VALUE . Now as I trace through I can see some recent changes in the updateTopDocs(...) method of QueryHits which now take into account pagination and pass my maxResults value (Integer.MAX_VALUE in my case) through to lucene. When it gets to lucene, there is code that attempts to add one to this and then use the results to create an array. Adding one to Integer.MAX_VALUE causes some sort of overflow, resulting in a negative number, hence the exception as outlined in the stacktrace.

Am I using the setMaxResults in a way that was unintended? Or is this post really for the folks at lucene?

Thanks for your help... Relevant details below.


Hibernate Version: 3.3.1.GA
Hibernate Search Version: 3.1.0.GA
Lucene Version: 3.3.1.GA

Code:
Stack Trace:
java.lang.NegativeArraySizeException
   at org.apache.lucene.util.PriorityQueue.initialize(PriorityQueue.java:41)
   at org.apache.lucene.search.HitQueue.<init>(HitQueue.java:24)
   at org.apache.lucene.search.TopDocCollector.<init>(TopDocCollector.java:44)
   at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:111)
   at org.apache.lucene.search.Searcher.search(Searcher.java:136)
   at org.hibernate.search.query.QueryHits.updateTopDocs(QueryHits.java:100)
   at org.hibernate.search.query.QueryHits.<init>(QueryHits.java:61)
   at org.hibernate.search.query.FullTextQueryImpl.getQueryHits(FullTextQueryImpl.java:354)
   at org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:270)
   at au.com.mycompany.core.dao.hibernate.search.FullTextSearchQuery.pagedResults(FullTextSearchQuery.java:147)
   at au.com.mycompany.core.dao.hibernate.HibernateMessageDao.searchForMessages(HibernateMessageDao.java:62)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
   at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:138)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at $Proxy51.searchForMessages(Unknown Source)
   at au.com.mycompany.core.service.search.impl.SearchServiceImpl.searchForMessageByCurrentMember(SearchServiceImpl.java:62)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
   at au.com.mycompany.core.service.security.accessresolver.annotation.SecureObjectMethodInterceptor.invoke(SecureObjectMethodInterceptor.java:60)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:160)
   at au.com.mycompany.core.service.validator.annotation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:48)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:160)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at $Proxy63.searchForMessageByCurrentMember(Unknown Source)
   at au.com.mycompany.core.service.search.impl.SearchServiceImplIntegrationTest.testSearch(SearchServiceImplIntegrationTest.java:77)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
   at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
   at org.unitils.UnitilsJUnit4TestClassRunner$TestListenerInvokingMethodRoadie.runTestMethod(UnitilsJUnit4TestClassRunner.java:170)
   at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
   at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
   at org.unitils.UnitilsJUnit4TestClassRunner$TestListenerInvokingMethodRoadie.runBeforesThenTestThenAfters(UnitilsJUnit4TestClassRunner.java:152)
   at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
   at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
   at org.unitils.UnitilsJUnit4TestClassRunner.invokeTestMethod(UnitilsJUnit4TestClassRunner.java:91)
   at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
   at org.unitils.UnitilsJUnit4TestClassRunner.access$000(UnitilsJUnit4TestClassRunner.java:40)
   at org.unitils.UnitilsJUnit4TestClassRunner$1.run(UnitilsJUnit4TestClassRunner.java:58)
   at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
   at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
   at org.unitils.UnitilsJUnit4TestClassRunner.run(UnitilsJUnit4TestClassRunner.java:64)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)






Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2008 12:20 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

thanks for your post and the excellent description of the problem. You are right that Search now uses the maxResults parameter to determine how many TopDocs to retrieve.

After quickly checking the Lucene API documentation, I couldn't find anything which would indicate any restrictions on the parameter n in Searcher.search(). Integer.MAX_VALUE should be a legal value (even though it seems strange to me to set max results to such a high value). I would say it is a Lucene bug. Maybe you want to ask this question on the Lucene forum and see what the folks there say. Feel free to create a Jira issue as well for Search. Either way we have to take care of it.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2008 6:38 pm 
Newbie

Joined: Tue Dec 16, 2008 11:06 pm
Posts: 3
OK, thanks.

Will raise this with the Lucene folks and depedning on the outcome may raise a search issue.

George.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2008 6:55 pm 
Newbie

Joined: Tue Dec 16, 2008 11:06 pm
Posts: 3
Looks like this issue is already known in lucene... Not sure if there is a resolution though...

http://issues.apache.org/jira/browse/LU ... l-tabpanel

George.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2008 10:50 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi George,

thanks for the work. I also created a issue in Hibernate Search for. If for nothing else the problem does not get lost.

http://opensource.atlassian.com/project ... SEARCH-330

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.