From 678a8664f6227f99c77db0b751da392231612c80 Mon Sep 17 00:00:00 2001 From: uboness Date: Sat, 9 Feb 2013 03:26:52 +0100 Subject: [PATCH] fixed a bug in PrioritizedThreadPoolExecutor: now execute(Runnable) verifies the command is added as PrioritizedRunnable --- .../util/concurrent/PrioritizedEsThreadPoolExecutor.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/elasticsearch/common/util/concurrent/PrioritizedEsThreadPoolExecutor.java b/src/main/java/org/elasticsearch/common/util/concurrent/PrioritizedEsThreadPoolExecutor.java index e22fd061946..29f3f3ed6c2 100644 --- a/src/main/java/org/elasticsearch/common/util/concurrent/PrioritizedEsThreadPoolExecutor.java +++ b/src/main/java/org/elasticsearch/common/util/concurrent/PrioritizedEsThreadPoolExecutor.java @@ -47,6 +47,14 @@ public class PrioritizedEsThreadPoolExecutor extends EsThreadPoolExecutor { super(corePoolSize, maximumPoolSize, keepAliveTime, unit, new PriorityBlockingQueue(initialWorkQueuSize), threadFactory, handler); } + @Override + public void execute(Runnable command) { + if (!(command instanceof PrioritizedRunnable)) { + command = PrioritizedRunnable.wrap(command, Priority.NORMAL); + } + super.execute(command); + } + @Override protected RunnableFuture newTaskFor(Runnable runnable, T value) { if (!(runnable instanceof PrioritizedRunnable)) {