From 9b2c39f75d0432a3f523da51053935727e82fde2 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Sun, 20 Jan 2008 18:35:26 +0000 Subject: [PATCH] LUCENE-1144: fix NPE during DW.abort after OOM error git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@613645 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/index/DocumentsWriter.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/java/org/apache/lucene/index/DocumentsWriter.java b/src/java/org/apache/lucene/index/DocumentsWriter.java index 5551012786c..cb47172bf3f 100644 --- a/src/java/org/apache/lucene/index/DocumentsWriter.java +++ b/src/java/org/apache/lucene/index/DocumentsWriter.java @@ -2883,13 +2883,13 @@ final class DocumentsWriter { } public void nextBuffer() { - bufferUpto++; - if (bufferUpto == buffers.length) { - byte[][] newBuffers = new byte[(int) (bufferUpto*1.5)][]; - System.arraycopy(buffers, 0, newBuffers, 0, bufferUpto); + if (1+bufferUpto == buffers.length) { + byte[][] newBuffers = new byte[(int) (buffers.length*1.5)][]; + System.arraycopy(buffers, 0, newBuffers, 0, buffers.length); buffers = newBuffers; } - buffer = buffers[bufferUpto] = getByteBlock(); + buffer = buffers[1+bufferUpto] = getByteBlock(); + bufferUpto++; byteUpto = 0; byteOffset += BYTE_BLOCK_SIZE; @@ -2956,13 +2956,13 @@ final class DocumentsWriter { } public void nextBuffer() { - bufferUpto++; - if (bufferUpto == buffers.length) { - char[][] newBuffers = new char[(int) (bufferUpto*1.5)][]; - System.arraycopy(buffers, 0, newBuffers, 0, bufferUpto); + if (1+bufferUpto == buffers.length) { + char[][] newBuffers = new char[(int) (buffers.length*1.5)][]; + System.arraycopy(buffers, 0, newBuffers, 0, buffers.length); buffers = newBuffers; } - buffer = buffers[bufferUpto] = getCharBlock(); + buffer = buffers[1+bufferUpto] = getCharBlock(); + bufferUpto++; byteUpto = 0; byteOffset += CHAR_BLOCK_SIZE;