aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-executor/plugins-executor-javascript/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-03-25 17:35:43 +0000
committerliamfallon <liam.fallon@est.tech>2020-03-25 17:38:25 +0000
commit4f0708ce15cc62662e3746262e8092913c24906e (patch)
tree197d835a1631916c618a5a6b9d3ba1f3dae67c0d /plugins/plugins-executor/plugins-executor-javascript/src
parent9aa62b777ddcd25665fdc1544934c133e0124230 (diff)
Add timeout on Javascript latch awaits
It is possible that the initiation and especially shutdown happens so fast that the execution thread counts down the latch before the caller calls await(), in which case the Javascript Rhino thread will hang. This review adds a timeout on the await calls. Issue-ID: POLICY-2106 Change-Id: Icfc6d4b478cca62522461c25d61ce9ee7328684a Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'plugins/plugins-executor/plugins-executor-javascript/src')
-rw-r--r--plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutor.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutor.java b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutor.java
index 2394b83d3..f7bafdd74 100644
--- a/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutor.java
@@ -23,6 +23,7 @@ package org.onap.policy.apex.plugins.executor.javascript;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.lang3.StringUtils;
@@ -102,7 +103,9 @@ public class JavascriptExecutor implements Runnable {
}
try {
- intializationLatch.await();
+ if (!intializationLatch.await(60, TimeUnit.SECONDS)) {
+ LOGGER.warn("JavascriptExecutor {}, initiation timed out", subjectKey.getId());
+ }
} catch (InterruptedException e) {
LOGGER.debug("JavascriptExecutor {} interrupted on execution thread startup", subjectKey.getId(), e);
Thread.currentThread().interrupt();
@@ -158,7 +161,9 @@ public class JavascriptExecutor implements Runnable {
executorThread.interrupt();
try {
- shutdownLatch.await();
+ if (!shutdownLatch.await(60, TimeUnit.SECONDS)) {
+ LOGGER.warn("JavascriptExecutor {}, shutdown timed out", subjectKey.getId());
+ }
} catch (InterruptedException e) {
LOGGER.debug("JavascriptExecutor {} interrupted on execution clkeanup wait", subjectKey.getId(), e);
Thread.currentThread().interrupt();