From 6e6ece76c0c58be7bc596524942a89c491c70c08 Mon Sep 17 00:00:00 2001 From: Will Fleming Date: Thu, 17 Dec 2015 17:43:27 -0500 Subject: [PATCH] Don't rescue ThreadError in FileThreadPool The previous implementation was blindly catching all ThreadError exceptions, because that's what `#pop(true)` raises when the queue is empty. However, there are other situations that would raise the same class that we definitely shouldn't be silently ignoring. This changes the code to actually check if the queue is empty before popping, and removes the rescue entirely: if exceptions happen, we want to know. --- lib/cc/engine/analyzers/file_thread_pool.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/cc/engine/analyzers/file_thread_pool.rb b/lib/cc/engine/analyzers/file_thread_pool.rb index f369ab07..971df120 100644 --- a/lib/cc/engine/analyzers/file_thread_pool.rb +++ b/lib/cc/engine/analyzers/file_thread_pool.rb @@ -17,11 +17,8 @@ def run(&block) @workers = thread_count.times.map do Thread.new do - begin - while item = queue.pop(true) - yield item - end - rescue ThreadError + while !queue.empty? && (item = queue.pop(true)) + yield item end end end