if a task is rejected, decrement semaphore

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1385012 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2012-09-15 04:51:18 +00:00
parent a215370b3a
commit 8ca9758dc4
1 changed files with 7 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
@ -353,7 +354,12 @@ public class SolrCmdDistributor {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "Update thread interrupted", e); throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "Update thread interrupted", e);
} }
pending.add(completionService.submit(task)); try {
pending.add(completionService.submit(task));
} catch (RejectedExecutionException e) {
semaphore.release();
throw e;
}
} }