diff --git a/src/main/java/org/elasticsearch/threadpool/ThreadPool.java b/src/main/java/org/elasticsearch/threadpool/ThreadPool.java index 58e0d8b0c7f..10bed455029 100644 --- a/src/main/java/org/elasticsearch/threadpool/ThreadPool.java +++ b/src/main/java/org/elasticsearch/threadpool/ThreadPool.java @@ -479,7 +479,9 @@ public class ThreadPool extends AbstractComponent { private BlockingQueue newQueue(SizeValue queueSize, String queueType) { if (queueSize == null) { return ConcurrentCollections.newBlockingQueue(); - } else if ((int) queueSize.singles() > 0) { + } else if (queueSize.singles() == 0) { + return new SynchronousQueue(); + } else if (queueSize.singles() > 0) { if ("linked".equals(queueType)) { return new LinkedBlockingQueue((int) queueSize.singles()); } else if ("array".equals(queueType)) { @@ -487,8 +489,8 @@ public class ThreadPool extends AbstractComponent { } else { throw new ElasticSearchIllegalArgumentException("illegal queue_type set to [" + queueType + "], should be either linked or array"); } - } else { - return new SynchronousQueue(); + } else { // queueSize.singles() < 0, just treat it as unbounded queue + return ConcurrentCollections.newBlockingQueue(); } }