Index: java/org/apache/lucene/analysis/Token.java
===================================================================
--- java/org/apache/lucene/analysis/Token.java	(revision 797848)
+++ java/org/apache/lucene/analysis/Token.java	(working copy)
@@ -384,10 +384,7 @@
    */
   public final void setTermBuffer(char[] buffer, int offset, int length) {
     termText = null;
-    char[] newCharBuffer = growTermBuffer(length);
-    if (newCharBuffer != null) {
-      termBuffer = newCharBuffer;
-    }
+    growTermBuffer(length);
     System.arraycopy(buffer, offset, termBuffer, 0, length);
     termLength = length;
   }
@@ -397,11 +394,8 @@
    */
   public final void setTermBuffer(String buffer) {
     termText = null;
-    int length = buffer.length();
-    char[] newCharBuffer = growTermBuffer(length);
-    if (newCharBuffer != null) {
-      termBuffer = newCharBuffer;
-    }
+    final int length = buffer.length();
+    growTermBuffer(length);
     buffer.getChars(0, length, termBuffer, 0);
     termLength = length;
   }
@@ -416,10 +410,7 @@
     assert offset <= buffer.length();
     assert offset + length <= buffer.length();
     termText = null;
-    char[] newCharBuffer = growTermBuffer(length);
-    if (newCharBuffer != null) {
-      termBuffer = newCharBuffer;
-    }
+    growTermBuffer(length);
     buffer.getChars(offset, offset + length, termBuffer, 0);
     termLength = length;
   }
@@ -447,57 +438,53 @@
    *  @return newly created termBuffer with length >= newSize
    */
   public char[] resizeTermBuffer(int newSize) {
-    char[] newCharBuffer = growTermBuffer(newSize);
-    if (termBuffer == null) {
-      // If there were termText, then preserve it.
-      // note that if termBuffer is null then newCharBuffer cannot be null
-      assert newCharBuffer != null;
-      if (termText != null) {
-        termText.getChars(0, termText.length(), newCharBuffer, 0);
+    if (termBuffer != null) {
+      if(termBuffer.length < newSize){
+        // Not big enough; create a new array with slight
+        // over allocation and preserve content
+        final char[] newCharBuffer = new char[ArrayUtil.getNextSize(newSize)];
+        System.arraycopy(termBuffer, 0, newCharBuffer, 0, termBuffer.length);
+        termBuffer = newCharBuffer;
       }
-      termBuffer = newCharBuffer;
-    } else if (newCharBuffer != null) {
-      // Note: if newCharBuffer != null then termBuffer needs to grow.
-      // If there were a termBuffer, then preserve it
-      System.arraycopy(termBuffer, 0, newCharBuffer, 0, termBuffer.length);
-      termBuffer = newCharBuffer;      
+      return termBuffer;
+    } 
+    
+    // (termBuffer == null) case
+    // The buffer is always at least MIN_BUFFER_SIZE
+    newSize = newSize < MIN_BUFFER_SIZE ? MIN_BUFFER_SIZE : newSize;
+    //Preserve termText 
+    if (termText != null) {
+      final int ttLen = termText.length();
+      newSize = newSize < ttLen ? ttLen : newSize;
+      termBuffer = new char[ArrayUtil.getNextSize(newSize)];
+      termText.getChars(0, termText.length(), termBuffer, 0);
+      termText = null;
+    } else{// no term Text, the first allocation
+      termBuffer = new char[ArrayUtil.getNextSize(newSize)];
     }
-    termText = null;
-    return termBuffer;
+    
+    return termBuffer;   
   }
 
-  /** Allocates a buffer char[] of at least newSize
+  /** Allocates a buffer char[] of at least newSize, without preserving the existing content.
+   * its always used in places that set the content 
    *  @param newSize minimum size of the buffer
-   *  @return newly created buffer with length >= newSize or null if the current termBuffer is big enough
    */
-  private char[] growTermBuffer(int newSize) {
+  private void growTermBuffer(int newSize) {
     if (termBuffer != null) {
-      if (termBuffer.length >= newSize)
-        // Already big enough
-        return null;
-      else
+      if(termBuffer.length < newSize){
         // Not big enough; create a new array with slight
         // over allocation:
-        return new char[ArrayUtil.getNextSize(newSize)];
-    } else {
-
-      // determine the best size
-      // The buffer is always at least MIN_BUFFER_SIZE
-      if (newSize < MIN_BUFFER_SIZE) {
-        newSize = MIN_BUFFER_SIZE;
+        termBuffer = new char[ArrayUtil.getNextSize(newSize)];
       }
-
-      // If there is already a termText, then the size has to be at least that big
-      if (termText != null) {
-        int ttLength = termText.length();
-        if (newSize < ttLength) {
-          newSize = ttLength;
-        }
-      }
-
-      return new char[newSize];
-    }
+      return;
+    } 
+    
+    // termBuffer == null
+    // The buffer is always at least MIN_BUFFER_SIZE    
+    termBuffer = new char[ArrayUtil.getNextSize(newSize < MIN_BUFFER_SIZE ? MIN_BUFFER_SIZE : newSize)];   
   }
+  
 
   // TODO: once we remove the deprecated termText() method
   // and switch entirely to char[] termBuffer we don't need
@@ -505,12 +492,12 @@
   private void initTermBuffer() {
     if (termBuffer == null) {
       if (termText == null) {
-        termBuffer = new char[MIN_BUFFER_SIZE];
+        termBuffer = new char[ArrayUtil.getNextSize(MIN_BUFFER_SIZE)];
         termLength = 0;
       } else {
         int length = termText.length();
         if (length < MIN_BUFFER_SIZE) length = MIN_BUFFER_SIZE;
-        termBuffer = new char[length];
+        termBuffer = new char[ArrayUtil.getNextSize(length)];
         termLength = termText.length();
         termText.getChars(0, termText.length(), termBuffer, 0);
         termText = null;
Index: java/org/apache/lucene/analysis/tokenattributes/TermAttributeImpl.java
===================================================================
--- java/org/apache/lucene/analysis/tokenattributes/TermAttributeImpl.java	(revision 797848)
+++ java/org/apache/lucene/analysis/tokenattributes/TermAttributeImpl.java	(working copy)
@@ -52,10 +52,7 @@
    *  @param length the number of characters to copy
    */
   public void setTermBuffer(char[] buffer, int offset, int length) {
-    char[] newCharBuffer = growTermBuffer(length);
-    if (newCharBuffer != null) {
-      termBuffer = newCharBuffer;
-    }
+    growTermBuffer(length);
     System.arraycopy(buffer, offset, termBuffer, 0, length);
     termLength = length;
   }
@@ -65,10 +62,7 @@
    */
   public void setTermBuffer(String buffer) {
     int length = buffer.length();
-    char[] newCharBuffer = growTermBuffer(length);
-    if (newCharBuffer != null) {
-      termBuffer = newCharBuffer;
-    }
+    growTermBuffer(length);
     buffer.getChars(0, length, termBuffer, 0);
     termLength = length;
   }
@@ -82,10 +76,7 @@
   public void setTermBuffer(String buffer, int offset, int length) {
     assert offset <= buffer.length();
     assert offset + length <= buffer.length();
-    char[] newCharBuffer = growTermBuffer(length);
-    if (newCharBuffer != null) {
-      termBuffer = newCharBuffer;
-    }
+    growTermBuffer(length);
     buffer.getChars(offset, offset + length, termBuffer, 0);
     termLength = length;
   }
@@ -113,52 +104,49 @@
    *  @return newly created termBuffer with length >= newSize
    */
   public char[] resizeTermBuffer(int newSize) {
-    char[] newCharBuffer = growTermBuffer(newSize);
-    if (termBuffer == null) {
-      // If there were termText, then preserve it.
-      // note that if termBuffer is null then newCharBuffer cannot be null
-      assert newCharBuffer != null;
-      termBuffer = newCharBuffer;
-    } else if (newCharBuffer != null) {
-      // Note: if newCharBuffer != null then termBuffer needs to grow.
-      // If there were a termBuffer, then preserve it
-      System.arraycopy(termBuffer, 0, newCharBuffer, 0, termBuffer.length);
-      termBuffer = newCharBuffer;      
-    }
-    return termBuffer;
+    if (termBuffer != null) {
+      if(termBuffer.length < newSize){
+        // Not big enough; create a new array with slight
+        // over allocation and preserve content
+        final char[] newCharBuffer = new char[ArrayUtil.getNextSize(newSize)];
+        System.arraycopy(termBuffer, 0, newCharBuffer, 0, termBuffer.length);
+        termBuffer = newCharBuffer;
+      }
+      return termBuffer;
+    } 
+    
+    // (termBuffer == null) case
+    // The buffer is always at least MIN_BUFFER_SIZE
+    termBuffer = new char[ArrayUtil.getNextSize(newSize < MIN_BUFFER_SIZE ? MIN_BUFFER_SIZE : newSize)]; 
+    return termBuffer;   
   }
 
-  /** Allocates a buffer char[] of at least newSize
+
+  /** Allocates a buffer char[] of at least newSize, without preserving the existing content.
+   * its always used in places that set the content 
    *  @param newSize minimum size of the buffer
-   *  @return newly created buffer with length >= newSize or null if the current termBuffer is big enough
    */
-  private char[] growTermBuffer(int newSize) {
+  private void growTermBuffer(int newSize) {
     if (termBuffer != null) {
-      if (termBuffer.length >= newSize)
-        // Already big enough
-        return null;
-      else
+      if(termBuffer.length < newSize){
         // Not big enough; create a new array with slight
         // over allocation:
-        return new char[ArrayUtil.getNextSize(newSize)];
-    } else {
-
-      // determine the best size
-      // The buffer is always at least MIN_BUFFER_SIZE
-      if (newSize < MIN_BUFFER_SIZE) {
-        newSize = MIN_BUFFER_SIZE;
+        termBuffer = new char[ArrayUtil.getNextSize(newSize)];
       }
-
-      return new char[newSize];
-    }
+      return;
+    } 
+    // termBuffer == null
+    // The buffer is always at least MIN_BUFFER_SIZE
+    termBuffer = new char[ArrayUtil.getNextSize(newSize < MIN_BUFFER_SIZE ? MIN_BUFFER_SIZE : newSize)];   
   }
-
+  
+  
   // TODO: once we remove the deprecated termText() method
   // and switch entirely to char[] termBuffer we don't need
   // to use this method anymore
   private void initTermBuffer() {
     if (termBuffer == null) {
-        termBuffer = new char[MIN_BUFFER_SIZE];
+        termBuffer = new char[ArrayUtil.getNextSize(MIN_BUFFER_SIZE)];
         termLength = 0;
     }
   }
Index: test/org/apache/lucene/analysis/TestToken.java
===================================================================
--- test/org/apache/lucene/analysis/TestToken.java	(revision 797848)
+++ test/org/apache/lucene/analysis/TestToken.java	(working copy)
@@ -122,7 +122,7 @@
       buf.append("a");
     }
     assertEquals(20000, t.termLength());
-    assertEquals(20331, t.termBuffer().length);
+    assertEquals(20167, t.termBuffer().length);
 
     // Test for slow growth to a long term
     t = new Token();
@@ -136,7 +136,7 @@
       buf.append("a");
     }
     assertEquals(20000, t.termLength());
-    assertEquals(20331, t.termBuffer().length);
+    assertEquals(20167, t.termBuffer().length);
   }
 
   public void testToString() throws Exception {
