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)