From aa9b69564eefb10efdc7ff5d3ced623ff4022b4e Mon Sep 17 00:00:00 2001 From: Jerry D'Antonio Date: Wed, 26 Nov 2014 12:38:42 -0500 Subject: [PATCH] Fixed JavaThreadPoolExecutor queue bug when minimum pool size is zero. --- CHANGELOG.md | 1 + lib/concurrent/executor/java_thread_pool_executor.rb | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 589bac51b..1ba753ec6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Please see the [roadmap](https://github.com/ruby-concurrency/concurrent-ruby/iss * Added missing synchronizations to `TimerSet` * Fixed bug with return value of `Concurrent::Actor::Utils::Pool#ask` * Fixed timing bug in `TimerTask` +* Fixed bug when creating a `JavaThreadPoolExecutor` with minimum pool size of zero * Removed confusing warning when not using native extenstions * Improved documentation diff --git a/lib/concurrent/executor/java_thread_pool_executor.rb b/lib/concurrent/executor/java_thread_pool_executor.rb index a00396995..1660c3dee 100644 --- a/lib/concurrent/executor/java_thread_pool_executor.rb +++ b/lib/concurrent/executor/java_thread_pool_executor.rb @@ -74,9 +74,7 @@ def initialize(opts = {}) raise ArgumentError.new('min_threads cannot be more than max_threads') if min_length > max_length raise ArgumentError.new("#{@overflow_policy} is not a valid overflow policy") unless OVERFLOW_POLICIES.keys.include?(@overflow_policy) - if min_length == 0 && @max_queue == 0 - queue = java.util.concurrent.SynchronousQueue.new - elsif @max_queue == 0 + if @max_queue == 0 queue = java.util.concurrent.LinkedBlockingQueue.new else queue = java.util.concurrent.LinkedBlockingQueue.new(@max_queue) @@ -90,7 +88,7 @@ def initialize(opts = {}) set_shutdown_hook end - # @!macro executor_module_method_can_overflow_question + # @!macro executor_module_method_can_overflow_question def can_overflow? @max_queue != 0 end