You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Robert Newson (JIRA)" <ji...@apache.org> on 2009/01/02 17:09:44 UTC
[jira] Created: (LUCENE-1510) InstantiatedIndexReader throws
NullPointerException in norms() when used with a MultiReader
InstantiatedIndexReader throws NullPointerException in norms() when used with a MultiReader
-------------------------------------------------------------------------------------------
Key: LUCENE-1510
URL: https://issues.apache.org/jira/browse/LUCENE-1510
Project: Lucene - Java
Issue Type: Bug
Components: contrib/*
Affects Versions: 2.4
Reporter: Robert Newson
When using InstantiatedIndexReader under a MultiReader where the other Reader contains documents, a NullPointerException is thrown here;
public void norms(String field, byte[] bytes, int offset) throws IOException {
byte[] norms = getIndex().getNormsByFieldNameAndDocumentNumber().get(field);
System.arraycopy(norms, 0, bytes, offset, norms.length);
}
the 'norms' variable is null. Performing the copy only when norms is not null does work, though I'm sure it's not the right fix.
java.lang.NullPointerException
at org.apache.lucene.store.instantiated.InstantiatedIndexReader.norms(InstantiatedIndexReader.java:297)
at org.apache.lucene.index.MultiReader.norms(MultiReader.java:273)
at org.apache.lucene.search.TermQuery$TermWeight.scorer(TermQuery.java:70)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:131)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:112)
at org.apache.lucene.search.Searcher.search(Searcher.java:136)
at org.apache.lucene.search.Searcher.search(Searcher.java:146)
at org.apache.lucene.store.instantiated.TestWithMultiReader.test(TestWithMultiReader.java:41)
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 junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
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)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
[jira] Commented: (LUCENE-1510) InstantiatedIndexReader throws
NullPointerException in norms() when used with a MultiReader
Posted by "Karl Wettin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-1510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12661908#action_12661908 ]
Karl Wettin commented on LUCENE-1510:
-------------------------------------
Thanks for the report Robert!
I've committed a fix in revision 732661. Please check it out and let me know how it works for you. There was a bit of discrepancies between how the InstantiatedIndexReader handled null norms compared to a SegmentReader. I think these problems are fixed now.
> InstantiatedIndexReader throws NullPointerException in norms() when used with a MultiReader
> -------------------------------------------------------------------------------------------
>
> Key: LUCENE-1510
> URL: https://issues.apache.org/jira/browse/LUCENE-1510
> Project: Lucene - Java
> Issue Type: Bug
> Components: contrib/*
> Affects Versions: 2.4
> Reporter: Robert Newson
> Assignee: Karl Wettin
> Attachments: TestWithMultiReader.java
>
>
> When using InstantiatedIndexReader under a MultiReader where the other Reader contains documents, a NullPointerException is thrown here;
> public void norms(String field, byte[] bytes, int offset) throws IOException {
> byte[] norms = getIndex().getNormsByFieldNameAndDocumentNumber().get(field);
> System.arraycopy(norms, 0, bytes, offset, norms.length);
> }
> the 'norms' variable is null. Performing the copy only when norms is not null does work, though I'm sure it's not the right fix.
> java.lang.NullPointerException
> at org.apache.lucene.store.instantiated.InstantiatedIndexReader.norms(InstantiatedIndexReader.java:297)
> at org.apache.lucene.index.MultiReader.norms(MultiReader.java:273)
> at org.apache.lucene.search.TermQuery$TermWeight.scorer(TermQuery.java:70)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:131)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:112)
> at org.apache.lucene.search.Searcher.search(Searcher.java:136)
> at org.apache.lucene.search.Searcher.search(Searcher.java:146)
> at org.apache.lucene.store.instantiated.TestWithMultiReader.test(TestWithMultiReader.java:41)
> 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 junit.framework.TestCase.runTest(TestCase.java:164)
> at junit.framework.TestCase.runBare(TestCase.java:130)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:120)
> at junit.framework.TestSuite.runTest(TestSuite.java:230)
> at junit.framework.TestSuite.run(TestSuite.java:225)
> at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 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)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
[jira] Updated: (LUCENE-1510) InstantiatedIndexReader throws
NullPointerException in norms() when used with a MultiReader
Posted by "Robert Newson (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-1510?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Robert Newson updated LUCENE-1510:
----------------------------------
Attachment: TestWithMultiReader.java
Test case to demonstrate NPE.
> InstantiatedIndexReader throws NullPointerException in norms() when used with a MultiReader
> -------------------------------------------------------------------------------------------
>
> Key: LUCENE-1510
> URL: https://issues.apache.org/jira/browse/LUCENE-1510
> Project: Lucene - Java
> Issue Type: Bug
> Components: contrib/*
> Affects Versions: 2.4
> Reporter: Robert Newson
> Attachments: TestWithMultiReader.java
>
>
> When using InstantiatedIndexReader under a MultiReader where the other Reader contains documents, a NullPointerException is thrown here;
> public void norms(String field, byte[] bytes, int offset) throws IOException {
> byte[] norms = getIndex().getNormsByFieldNameAndDocumentNumber().get(field);
> System.arraycopy(norms, 0, bytes, offset, norms.length);
> }
> the 'norms' variable is null. Performing the copy only when norms is not null does work, though I'm sure it's not the right fix.
> java.lang.NullPointerException
> at org.apache.lucene.store.instantiated.InstantiatedIndexReader.norms(InstantiatedIndexReader.java:297)
> at org.apache.lucene.index.MultiReader.norms(MultiReader.java:273)
> at org.apache.lucene.search.TermQuery$TermWeight.scorer(TermQuery.java:70)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:131)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:112)
> at org.apache.lucene.search.Searcher.search(Searcher.java:136)
> at org.apache.lucene.search.Searcher.search(Searcher.java:146)
> at org.apache.lucene.store.instantiated.TestWithMultiReader.test(TestWithMultiReader.java:41)
> 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 junit.framework.TestCase.runTest(TestCase.java:164)
> at junit.framework.TestCase.runBare(TestCase.java:130)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:120)
> at junit.framework.TestSuite.runTest(TestSuite.java:230)
> at junit.framework.TestSuite.run(TestSuite.java:225)
> at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 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)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
[jira] Closed: (LUCENE-1510) InstantiatedIndexReader throws
NullPointerException in norms() when used with a MultiReader
Posted by "Karl Wettin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-1510?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Karl Wettin closed LUCENE-1510.
-------------------------------
Resolution: Fixed
Fix Version/s: 2.9
> InstantiatedIndexReader throws NullPointerException in norms() when used with a MultiReader
> -------------------------------------------------------------------------------------------
>
> Key: LUCENE-1510
> URL: https://issues.apache.org/jira/browse/LUCENE-1510
> Project: Lucene - Java
> Issue Type: Bug
> Components: contrib/*
> Affects Versions: 2.4
> Reporter: Robert Newson
> Assignee: Karl Wettin
> Fix For: 2.9
>
> Attachments: TestWithMultiReader.java
>
>
> When using InstantiatedIndexReader under a MultiReader where the other Reader contains documents, a NullPointerException is thrown here;
> public void norms(String field, byte[] bytes, int offset) throws IOException {
> byte[] norms = getIndex().getNormsByFieldNameAndDocumentNumber().get(field);
> System.arraycopy(norms, 0, bytes, offset, norms.length);
> }
> the 'norms' variable is null. Performing the copy only when norms is not null does work, though I'm sure it's not the right fix.
> java.lang.NullPointerException
> at org.apache.lucene.store.instantiated.InstantiatedIndexReader.norms(InstantiatedIndexReader.java:297)
> at org.apache.lucene.index.MultiReader.norms(MultiReader.java:273)
> at org.apache.lucene.search.TermQuery$TermWeight.scorer(TermQuery.java:70)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:131)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:112)
> at org.apache.lucene.search.Searcher.search(Searcher.java:136)
> at org.apache.lucene.search.Searcher.search(Searcher.java:146)
> at org.apache.lucene.store.instantiated.TestWithMultiReader.test(TestWithMultiReader.java:41)
> 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 junit.framework.TestCase.runTest(TestCase.java:164)
> at junit.framework.TestCase.runBare(TestCase.java:130)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:120)
> at junit.framework.TestSuite.runTest(TestSuite.java:230)
> at junit.framework.TestSuite.run(TestSuite.java:225)
> at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 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)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
[jira] Commented: (LUCENE-1510) InstantiatedIndexReader throws
NullPointerException in norms() when used with a MultiReader
Posted by "Robert Newson (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-1510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12661956#action_12661956 ]
Robert Newson commented on LUCENE-1510:
---------------------------------------
Looks good to me. I wonder if you should add;
private static final byte[] EMPTY = new byte[0];
and refer to that, as your todo suggests?
> InstantiatedIndexReader throws NullPointerException in norms() when used with a MultiReader
> -------------------------------------------------------------------------------------------
>
> Key: LUCENE-1510
> URL: https://issues.apache.org/jira/browse/LUCENE-1510
> Project: Lucene - Java
> Issue Type: Bug
> Components: contrib/*
> Affects Versions: 2.4
> Reporter: Robert Newson
> Assignee: Karl Wettin
> Fix For: 2.9
>
> Attachments: TestWithMultiReader.java
>
>
> When using InstantiatedIndexReader under a MultiReader where the other Reader contains documents, a NullPointerException is thrown here;
> public void norms(String field, byte[] bytes, int offset) throws IOException {
> byte[] norms = getIndex().getNormsByFieldNameAndDocumentNumber().get(field);
> System.arraycopy(norms, 0, bytes, offset, norms.length);
> }
> the 'norms' variable is null. Performing the copy only when norms is not null does work, though I'm sure it's not the right fix.
> java.lang.NullPointerException
> at org.apache.lucene.store.instantiated.InstantiatedIndexReader.norms(InstantiatedIndexReader.java:297)
> at org.apache.lucene.index.MultiReader.norms(MultiReader.java:273)
> at org.apache.lucene.search.TermQuery$TermWeight.scorer(TermQuery.java:70)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:131)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:112)
> at org.apache.lucene.search.Searcher.search(Searcher.java:136)
> at org.apache.lucene.search.Searcher.search(Searcher.java:146)
> at org.apache.lucene.store.instantiated.TestWithMultiReader.test(TestWithMultiReader.java:41)
> 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 junit.framework.TestCase.runTest(TestCase.java:164)
> at junit.framework.TestCase.runBare(TestCase.java:130)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:120)
> at junit.framework.TestSuite.runTest(TestSuite.java:230)
> at junit.framework.TestSuite.run(TestSuite.java:225)
> at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 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)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
[jira] Assigned: (LUCENE-1510) InstantiatedIndexReader throws
NullPointerException in norms() when used with a MultiReader
Posted by "Karl Wettin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-1510?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Karl Wettin reassigned LUCENE-1510:
-----------------------------------
Assignee: Karl Wettin
> InstantiatedIndexReader throws NullPointerException in norms() when used with a MultiReader
> -------------------------------------------------------------------------------------------
>
> Key: LUCENE-1510
> URL: https://issues.apache.org/jira/browse/LUCENE-1510
> Project: Lucene - Java
> Issue Type: Bug
> Components: contrib/*
> Affects Versions: 2.4
> Reporter: Robert Newson
> Assignee: Karl Wettin
> Attachments: TestWithMultiReader.java
>
>
> When using InstantiatedIndexReader under a MultiReader where the other Reader contains documents, a NullPointerException is thrown here;
> public void norms(String field, byte[] bytes, int offset) throws IOException {
> byte[] norms = getIndex().getNormsByFieldNameAndDocumentNumber().get(field);
> System.arraycopy(norms, 0, bytes, offset, norms.length);
> }
> the 'norms' variable is null. Performing the copy only when norms is not null does work, though I'm sure it's not the right fix.
> java.lang.NullPointerException
> at org.apache.lucene.store.instantiated.InstantiatedIndexReader.norms(InstantiatedIndexReader.java:297)
> at org.apache.lucene.index.MultiReader.norms(MultiReader.java:273)
> at org.apache.lucene.search.TermQuery$TermWeight.scorer(TermQuery.java:70)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:131)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:112)
> at org.apache.lucene.search.Searcher.search(Searcher.java:136)
> at org.apache.lucene.search.Searcher.search(Searcher.java:146)
> at org.apache.lucene.store.instantiated.TestWithMultiReader.test(TestWithMultiReader.java:41)
> 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 junit.framework.TestCase.runTest(TestCase.java:164)
> at junit.framework.TestCase.runBare(TestCase.java:130)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:120)
> at junit.framework.TestSuite.runTest(TestSuite.java:230)
> at junit.framework.TestSuite.run(TestSuite.java:225)
> at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 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)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org