NullPointerException during IndexWriter.mergeSegments
-----------------------------------------------------
Key: LUCENE-480
URL: http://issues.apache.org/jira/browse/LUCENE-480
Project: Lucene - Java
Type: Bug
Components: Index
Versions: CVS Nightly - Specify date in submission, 1.9
Environment: 64bit, ubuntu, Java 5 SE
Reporter: Jeremy Calvert
Last commit on culprit org.apache.lucene.index.FieldsReader: Sun Oct 30
05:38:46 2005.
---------------------------------------------------------
Offending code in FieldsReader.java:
...
final Document doc(int n) throws IOException {
indexStream.seek(n * 8L);
long position = indexStream.readLong();
fieldsStream.seek(position);
Document doc = new Document();
int numFields = fieldsStream.readVInt();
for (int i = 0; i < numFields; i++) {
int fieldNumber = fieldsStream.readVInt();
FieldInfo fi = fieldInfos.fieldInfo(fieldNumber);
//
// This apparently returns null, presumably either as a result of:
// catch (IndexOutOfBoundsException ioobe) {
// return null;
// }
// in fieldInfos.fieldInfo(int fieldNumber)
// - or -
// because there's a null member of member ArrayList byNumber of FieldInfos
byte bits = fieldsStream.readByte();
boolean compressed = (bits & FieldsWriter.FIELD_IS_COMPRESSED) != 0;
....
Field.Store store = Field.Store.YES;
//
// Here --v is where the NPE is thrown.
if (fi.isIndexed && tokenize)
index = Field.Index.TOKENIZED;
...
---------------------------------------------------------
Proposed Patch:
I'm not sure what the behavior should be in this case, but if it's no big deal
that there's null field info for an index and we should just ignore that index,
an obvious patch could be:
In FieldsReader.java:
...
for (int i = 0; i < numFields; i++) {
int fieldNumber = fieldsStream.readVInt();
FieldInfo fi = fieldInfos.fieldInfo(fieldNumber);
// vvvPatchvvv
if(fi == null) {continue;}
byte bits = fieldsStream.readByte();
...
---------------------------------------------------------
Other observations:
In my search prior to submitting this issue, I found LUCENE-168, which looks
similar, and is perhaps related, but if so, I'm not sure exactly how.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]