From 12249e5a08e40c550786edc83abd9d11454002fb Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Fri, 5 May 2017 13:43:17 -0400 Subject: [PATCH] NIFI-2268: Instead of allowing HandleHttpRequest to run constantly calling BlockingQueue.poll() as fast as possible, call BlockingQueue.poll(2, TimeUnit.MILLISECONDS) to avoid overutilization of CPU when there is no work to be done This closes #1762. Signed-off-by: Bryan Bende --- .../nifi/processors/standard/HandleHttpRequest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java index 19fa943967..3dd46f9fce 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java @@ -484,7 +484,14 @@ public class HandleHttpRequest extends AbstractProcessor { throw new ProcessException("Failed to initialize the server",e); } - final HttpRequestContainer container = containerQueue.poll(); + HttpRequestContainer container; + try { + container = containerQueue.poll(2, TimeUnit.MILLISECONDS); + } catch (final InterruptedException e1) { + Thread.currentThread().interrupt(); + return; + } + if (container == null) { return; }