From 34edcdc5154acd8012bf213b2346e36c1dcd7669 Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Fri, 4 Apr 2014 20:30:07 +0000 Subject: [PATCH] Remove crazy scanning for method, its easier that way! git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1584894 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/util/LuceneTestCase.java | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java index cfa233c607d..7ac506f6356 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java +++ b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java @@ -759,28 +759,13 @@ public abstract class LuceneTestCase extends Assert { int maxNumThreadStates = rarely(r) ? TestUtil.nextInt(r, 5, 20) // crazy value : TestUtil.nextInt(r, 1, 4); // reasonable value - Method setIndexerThreadPoolMethod = null; - try { - // Retrieve the package-private setIndexerThreadPool - // method: - for(Method m : IndexWriterConfig.class.getDeclaredMethods()) { - if (m.getName().equals("setIndexerThreadPool")) { - m.setAccessible(true); - setIndexerThreadPoolMethod = m; - break; - } - } - } catch (Exception e) { - // Should not happen? - Rethrow.rethrow(e); - } - - if (setIndexerThreadPoolMethod == null) { - throw new RuntimeException("failed to lookup IndexWriterConfig.setIndexerThreadPool method"); - } - try { if (rarely(r)) { + // Retrieve the package-private setIndexerThreadPool + // method: + Method setIndexerThreadPoolMethod = IndexWriterConfig.class.getDeclaredMethod("setIndexerThreadPool", + Class.forName("org.apache.lucene.index.DocumentsWriterPerThreadPool")); + setIndexerThreadPoolMethod.setAccessible(true); Class clazz = Class.forName("org.apache.lucene.index.RandomDocumentsWriterPerThreadPool"); Constructor ctor = clazz.getConstructor(int.class, Random.class); ctor.setAccessible(true);