LUCENE-1314: fix reopen bug wrt fields that don't have norms

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@741838 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2009-02-07 03:30:24 +00:00
parent dbe0898d63
commit 5388a5c7ac
2 changed files with 6 additions and 1 deletions

View File

@ -722,7 +722,8 @@ class SegmentReader extends DirectoryIndexReader {
if (doClone || !fieldNormsChanged[i]) {
final String curField = fieldInfos.fieldInfo(i).name;
Norm norm = (Norm) this.norms.get(curField);
clone.norms.put(curField, norm.clone());
if (norm != null)
clone.norms.put(curField, norm.clone());
}
}

View File

@ -168,6 +168,8 @@ public class TestIndexReaderReopen extends LuceneTestCase {
for (int j=0; j<M; j++) {
Document doc = new Document();
doc.add(new Field("id", i+"_"+j, Store.YES, Index.NOT_ANALYZED));
doc.add(new Field("id2", i+"_"+j, Store.YES, Index.NOT_ANALYZED_NO_NORMS));
doc.add(new Field("id3", i+"_"+j, Store.YES, Index.NO));
iwriter.addDocument(doc);
if (i>0) {
int k = i-1;
@ -959,6 +961,8 @@ public class TestIndexReaderReopen extends LuceneTestCase {
sb.append("a");
sb.append(n);
doc.add(new Field("field1", sb.toString(), Store.YES, Index.ANALYZED));
doc.add(new Field("fielda", sb.toString(), Store.YES, Index.NOT_ANALYZED_NO_NORMS));
doc.add(new Field("fieldb", sb.toString(), Store.YES, Index.NO));
sb.append(" b");
sb.append(n);
for (int i = 1; i < numFields; i++) {