My earlier suggestion obviously wouldn't work. 15 is a bit mask, not the length :)
Either nextLevelArray should be initialized with length 16, or a Min could be taken: int level = Math.Min(slice[upto] & 15, DocumentsWriter.nextLevelArray.Length); -Will -----Original Message----- From: Will Palmeri [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2008 6:23 PM To: lucene-net-dev@incubator.apache.org Subject: IndexOutOfRangeException when adding Document to index I just checked out the 2.3.1 code from svn and built a fresh dll to try out with our existing codebase. (We had been using 2.0.5). A couple of my indexes are working just fine, but for one of them when I get to around 1000 documents, I get sporadic IndexOutOfRangeExceptions when calling IndexWriter.AddDocument(Document) I stepped through the code and drilled down to where the exception is getting thrown. When processing a single term in a given field, the method AllocSlice of the internal class ByteBlockPool in DocumentsWriter.cs is called. In AllocSlice, the variable level is computed by AND'ing a value from slice array with 15 (0xf). However, in the next line 'level' is used to index into DocumentsWriter.nextLevelArray. At runtime, this array was only of length 10, so occasionally when level was >= 10, the IndexOutOfRangeException would be thrown. On line 3410, nextLevelArray is initialized: internal static readonly int[] nextLevelArray = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 9}; I'm not familiar with the codebase, so I have no idea what this code does specifically. But it seems to me that line 3510 should be: int level = slice[upto] & DocumentsWriter.nextLevelArray.Length I'm looking forward to using 2.3.1, hope this helps! -Will imeem.com