lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brendan Grainger <brendan.grain...@gmail.com>
Subject Re: Closing directory in LuceneTestCase causes stacktrace
Date Fri, 29 Jun 2012 02:33:00 GMT
Hi Robert,

I am trying to close the Directory on the very last line of the method which is where the
exception is being thrown:

		assertEquals("cool cat", doc.get("contents"));
		
		writer.close();
		searcher.close();
		directory.close();  <= Crashes here with stack trace below. If I comment this out I get
the exception about not closing the reader.
	}

 java.lang.RuntimeException: MockDirectoryWrapper: cannot close: there are still open files:
{_0.tis=1, _0.frq=1, _0.fdx=1, _0.prx=1, _0.fdt=1}
	at org.apache.lucene.store.MockDirectoryWrapper.close(MockDirectoryWrapper.java:548)
	at com.kuripai.lucene.analysis.MetaphoneReplacementAnaylyzerTest.testKoolKat(MetaphoneReplacementAnaylyzerTest.java:57)
	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:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
	at org.apache.lucene.util.LuceneTestCase$SubclassSetupTeardownRule$1.evaluate(LuceneTestCase.java:630)
	at org.apache.lucene.util.LuceneTestCase$InternalSetupTeardownRule$1.evaluate(LuceneTestCase.java:536)
	at org.apache.lucene.util.SystemPropertiesInvariantRule$1.evaluate(SystemPropertiesInvariantRule.java:67)
	at org.apache.lucene.util.LuceneTestCase$TestResultInterceptorRule$1.evaluate(LuceneTestCase.java:457)
	at org.apache.lucene.util.UncaughtExceptionsRule$1.evaluate(UncaughtExceptionsRule.java:74)
	at org.apache.lucene.util.LuceneTestCase$SaveThreadAndTestNameRule$1.evaluate(LuceneTestCase.java:508)
	at org.junit.rules.RunRules.evaluate(RunRules.java:18)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
	at org.apache.lucene.util.LuceneTestCaseRunner.runChild(LuceneTestCaseRunner.java:146)
	at org.apache.lucene.util.LuceneTestCaseRunner.runChild(LuceneTestCaseRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
	at org.apache.lucene.util.UncaughtExceptionsRule$1.evaluate(UncaughtExceptionsRule.java:74)
	at org.apache.lucene.util.StoreClassNameRule$1.evaluate(StoreClassNameRule.java:36)
	at org.apache.lucene.util.SystemPropertiesInvariantRule$1.evaluate(SystemPropertiesInvariantRule.java:67)
	at org.junit.rules.RunRules.evaluate(RunRules.java:18)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.RuntimeException: unclosed IndexInput: _0.prx
	at org.apache.lucene.store.MockDirectoryWrapper.addFileHandle(MockDirectoryWrapper.java:472)
	at org.apache.lucene.store.MockDirectoryWrapper.openInput(MockDirectoryWrapper.java:497)
	at org.apache.lucene.store.Directory.openInput(Directory.java:145)
	at org.apache.lucene.index.SegmentCoreReaders.<init>(SegmentCoreReaders.java:96)
	at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:116)
	at org.apache.lucene.index.IndexWriter$ReaderPool.get(IndexWriter.java:696)
	at org.apache.lucene.index.IndexWriter$ReaderPool.getReadOnlyClone(IndexWriter.java:654)
	at org.apache.lucene.index.DirectoryReader.<init>(DirectoryReader.java:142)
	at org.apache.lucene.index.ReadOnlyDirectoryReader.<init>(ReadOnlyDirectoryReader.java:36)
	at org.apache.lucene.index.IndexWriter.getReader(IndexWriter.java:451)
	at org.apache.lucene.index.IndexWriter.getReader(IndexWriter.java:399)
	at org.apache.lucene.index.IndexReader.open(IndexReader.java:296)
	at com.kuripai.lucene.analysis.MetaphoneReplacementAnaylyzerTest.testKoolKat(MetaphoneReplacementAnaylyzerTest.java:40)
	... 39 more



Brendan Grainger
brendan.grainger@gmail.com
www.kuripai.com

On Jun 28, 2012, at 8:57 PM, Robert Muir wrote:

> On Thu, Jun 28, 2012 at 8:22 PM, Brendan Grainger
> <brendan.grainger@gmail.com> wrote:
>> 
>> Interestingly, if I change the *** line above to use the deprecated constructor taking
just the directory it works fine:
>> 
> 
> its not interesting at all, its the typical contract of a java method.
> he who opens it closes it.
> 
> I'll quote myself again:
> 
> in this case (where IndexSearcher takes a reader that you passed in),
> closing the searcher won't actually close the underlying reader.
> you passed it in, so you should be sure to close this reader yourself.
> 
> 
> -- 
> lucidimagination.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message