From c270fa8a2fe4ba4cdad7a73fd91066f69f4b8c45 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Fri, 20 Oct 2006 05:10:49 +0000 Subject: [PATCH] test demonstrating problem cloning active IndexInput in LazyField: LUCENE-690 git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@465995 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/search/TestThreadSafe.java | 156 ++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100755 src/test/org/apache/lucene/search/TestThreadSafe.java diff --git a/src/test/org/apache/lucene/search/TestThreadSafe.java b/src/test/org/apache/lucene/search/TestThreadSafe.java new file mode 100755 index 00000000000..a2b45f4dcc1 --- /dev/null +++ b/src/test/org/apache/lucene/search/TestThreadSafe.java @@ -0,0 +1,156 @@ +package org.apache.lucene.search; +/** + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import junit.framework.TestCase; +import org.apache.lucene.store.Directory; +import org.apache.lucene.store.RAMDirectory; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.analysis.WhitespaceAnalyzer; +import org.apache.lucene.document.*; + +import java.util.Random; +import java.util.List; +import java.io.IOException; + +/** + * @author yonik + * @version $Id$ + */ +public class TestThreadSafe extends TestCase { + Random r = new Random(); + Directory dir1; + Directory dir2; + + IndexReader ir1; + IndexReader ir2; + + String failure=null; + + + class Thr extends Thread { + final int iter; + final Random rand; + // pass in random in case we want to make things reproducable + public Thr(int iter, Random rand, int level) { + this.iter = iter; + this.rand = rand; + } + + public void run() { + try { + for (int i=0; i