[ 
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-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

Reply via email to