From 526d97676dd87e04c9324271d216a1d48f4944a8 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Mon, 29 Oct 2007 09:00:56 +0000 Subject: [PATCH] LUCENE-1036: make sure the priority argument to Thread.setPriority(...) in ConcurrentMergeScheduler is in-bounds git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@589549 13f79535-47bb-0310-9956-ffa450edef68 --- .../index/ConcurrentMergeScheduler.java | 40 ++++++++++++------- .../apache/lucene/index/TestIndexWriter.java | 21 ++++++++++ 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java b/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java index 28531d2fa53..7af6c262509 100644 --- a/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java +++ b/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java @@ -78,17 +78,14 @@ public class ConcurrentMergeScheduler implements MergeScheduler { /** Return the priority that merge threads run at. */ public synchronized void setMergeThreadPriority(int pri) { + if (pri > Thread.MAX_PRIORITY || pri < Thread.MIN_PRIORITY) + throw new IllegalArgumentException("priority must be in range " + Thread.MIN_PRIORITY + " .. " + Thread.MAX_PRIORITY + " inclusive"); mergeThreadPriority = pri; final int numThreads = mergeThreadCount(); for(int i=0;i Thread.MAX_PRIORITY) + mergeThreadPriority = Thread.MAX_PRIORITY; + } } public void close() { @@ -122,7 +122,12 @@ public class ConcurrentMergeScheduler implements MergeScheduler { } } private synchronized int mergeThreadCount() { - return mergeThreads.size(); + int count = 0; + final int numThreads = mergeThreads.size(); + for(int i=0;i= 20 (maxMergeDocs) docs private class MyMergeScheduler implements MergeScheduler {