From b7cc38c0bcebeafe0fef3ec9704c71374b39d29c Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 21 Jun 2013 04:25:03 +0000 Subject: [PATCH] LUCENE-5066: fix TestFieldsReader OOM (test bug) git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1495290 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/index/TestFieldsReader.java | 17 ++++++++++++----- .../util/TestRuleSetupAndRestoreClassEnv.java | 3 +++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java b/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java index 3be24a7c7be..052ad6fd2c7 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java @@ -170,12 +170,11 @@ public class TestFieldsReader extends LuceneTestCase { @Override public void readInternal(byte[] b, int offset, int length) throws IOException { simOutage(); + delegate.seek(getFilePointer()); delegate.readBytes(b, offset, length); } @Override public void seekInternal(long pos) throws IOException { - //simOutage(); - delegate.seek(pos); } @Override public long length() { @@ -187,7 +186,14 @@ public class TestFieldsReader extends LuceneTestCase { } @Override public FaultyIndexInput clone() { - return new FaultyIndexInput(delegate.clone()); + FaultyIndexInput i = new FaultyIndexInput(delegate.clone()); + // seek the clone to our current position + try { + i.seek(getFilePointer()); + } catch (IOException e) { + throw new RuntimeException(); + } + return i; } } @@ -197,8 +203,9 @@ public class TestFieldsReader extends LuceneTestCase { try { Directory dir = new FaultyFSDirectory(indexDir); - IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( - TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.CREATE)); + IndexWriterConfig iwc = newIndexWriterConfig( + TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.CREATE); + IndexWriter writer = new IndexWriter(dir, iwc); for(int i=0;i<2;i++) writer.addDocument(testDoc); writer.forceMerge(1); diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java index 7f31d48657d..01cbbcdcf20 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java +++ b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java @@ -84,6 +84,9 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule { @Override public void message(String component, String message) { + if ("TP".equals(component)) { + return; // ignore test points! + } final String name; if (Thread.currentThread().getName().startsWith("TEST-")) { // The name of the main thread is way too