summaryrefslogtreecommitdiffstats
path: root/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/MainLoop.java
diff options
context:
space:
mode:
Diffstat (limited to 'feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/MainLoop.java')
-rw-r--r--feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/MainLoop.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/MainLoop.java b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/MainLoop.java
index 4ae8b59b..ca5e86ac 100644
--- a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/MainLoop.java
+++ b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/MainLoop.java
@@ -84,7 +84,9 @@ class MainLoop extends Thread {
* @param work this is the Runnable to invoke
*/
public static void queueWork(Runnable work) {
- incomingWork.offer(work);
+ if (!incomingWork.offer(work)) {
+ logger.info("incomingWork returned false");
+ }
}
/**
@@ -143,11 +145,7 @@ class MainLoop extends Thread {
// work that runs every cycle
for (Runnable work : backgroundWork) {
- try {
- work.run();
- } catch (Exception e) {
- logger.error("Exception in MainLoop background work", e);
- }
+ backgroundWorkRunnable(work);
}
} catch (Exception e) {
logger.error("Exception in MainLoop", e);
@@ -156,6 +154,17 @@ class MainLoop extends Thread {
}
/**
+ * Runnable try loop.
+ */
+ static void backgroundWorkRunnable(Runnable work) {
+ try {
+ work.run();
+ } catch (Exception e) {
+ logger.error("Exception in MainLoop background work", e);
+ }
+ }
+
+ /**
* Poll for and process incoming messages for up to 1 second.
*/
static void handleIncomingWork() {