GateNLP / gate-core

The GATE Embedded core API and GATE Developer application
GNU Lesser General Public License v3.0
78 stars 29 forks source link

NPE in SerialCorpusImpl.java:742 #6

Closed johann-petrak closed 7 years ago

johann-petrak commented 7 years ago

when running the tests, when running testExplicitMimeType(gate.corpora.TestDocument) , it can happen that the following exception occurs:

    at gate.corpora.SerialCorpusImpl.findDocument(SerialCorpusImpl.java:742)
    at gate.corpora.SerialCorpusImpl.indexOf(SerialCorpusImpl.java:898)
    at gate.corpora.SerialCorpusImpl.resourceUnloaded(SerialCorpusImpl.java:479)
    at gate.creole.CreoleRegisterImpl.fireResourceUnloaded(CreoleRegisterImpl.java:1087)
    at gate.creole.CreoleRegisterImpl.resourceUnloaded(CreoleRegisterImpl.java:1140)
    at gate.CreoleProxy.fireResourceUnloaded(Factory.java:915)
    at gate.Factory.deleteResource(Factory.java:463)
    at gate.corpora.TestDocument.testExplicitMimeType(TestDocument.java:306)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at junit.framework.TestCase.runTest(TestCase.java:176)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.framework.TestSuite.runTest(TestSuite.java:252)
    at junit.framework.TestSuite.run(TestSuite.java:247)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

To allow the test to complete successfully a temporary NPE guard was added, but this should get investigated!

greenwoodma commented 7 years ago

The issue was that one of the other tests was creating a serial corpus, not providing a datastore, and then not deleting the corpus at the end of the test. For some reason the test order was different enough on the PC @johann-petrak was using to cause the left over corpus to interfere with the mime type test. I've fixed this by removing the weird serial corpus test as all the functionality being tested was already covered by TestPersist.