From 673cef5639f3f7e8e8abe29cc940fe7ce0dff2e4 Mon Sep 17 00:00:00 2001
From: Michael McCandless <mikemccand@apache.org>
Date: Tue, 10 May 2011 18:02:06 +0000
Subject: [PATCH] fix false test failure

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1101572 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/lucene/index/TestIndexWriter.java  | 20 +++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
index 90bf1cacc6d..e29ef531476 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -18,7 +18,6 @@ package org.apache.lucene.index;
  */
 
 import java.io.ByteArrayOutputStream;
-import java.io.File;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.io.Reader;
@@ -1130,10 +1129,12 @@ public class TestIndexWriter extends LuceneTestCase {
 
       while(true) {
         MergePolicy.OneMerge merge = writer.getNextMerge();
-        if (merge == null)
+        if (merge == null) {
           break;
-        for(int i=0;i<merge.segments.size();i++)
-          assert merge.segments.info(i).docCount < 20;
+        }
+        for(int i=0;i<merge.segments.size();i++) {
+          assert merge.segments.get(i).docCount < 20;
+        }
         writer.merge(merge);
       }
     }
@@ -2141,6 +2142,7 @@ public class TestIndexWriter extends LuceneTestCase {
           while(true) {
             if (w != null) {
               w.close();
+              w = null;
             }
             IndexWriterConfig conf = newIndexWriterConfig(
                                                           TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMaxBufferedDocs(2);
@@ -2186,10 +2188,12 @@ public class TestIndexWriter extends LuceneTestCase {
       if (!failed) {
         // clear interrupt state:
         Thread.interrupted();
-        try {
-          w.rollback();
-        } catch (IOException ioe) {
-          throw new RuntimeException(ioe);
+        if (w != null) {
+          try {
+            w.rollback();
+          } catch (IOException ioe) {
+            throw new RuntimeException(ioe);
+          }
         }
 
         try {