lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r613646 - /lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java
Date Sun, 20 Jan 2008 18:37:59 GMT
Author: mikemccand
Date: Sun Jan 20 10:37:58 2008
New Revision: 613646

URL: http://svn.apache.org/viewvc?rev=613646&view=rev
Log:
LUCENE-1144: fix NPE during DW.abort after OOM error

Modified:
    lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java

Modified: lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java?rev=613646&r1=613645&r2=613646&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java
(original)
+++ lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java
Sun Jan 20 10:37:58 2008
@@ -2883,13 +2883,13 @@
     }
 
     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 @@
     }
 
     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;



Mime
View raw message