You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/06/12 13:50:24 UTC

[camel] 01/08: CAMEL-13636: camel3 - SPI for ReactiveHelper so we can plugin different reactive engines

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-13636
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e81a4ca9eff14321cd2057dcda217474b7fdcf8a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jun 12 12:44:59 2019 +0200

    CAMEL-13636: camel3 - SPI for ReactiveHelper so we can plugin different reactive engines
---
 .../java/org/apache/camel/support/ReactiveHelper.java  | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ReactiveHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/ReactiveHelper.java
index 7e05636..06db5e6 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ReactiveHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ReactiveHelper.java
@@ -22,6 +22,9 @@ import org.apache.camel.AsyncCallback;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * A basic reactive engine that uses a worker pool to process tasks.
+ */
 public final class ReactiveHelper {
 
     private static final ThreadLocal<Worker> WORKERS = ThreadLocal.withInitial(Worker::new);
@@ -51,6 +54,10 @@ public final class ReactiveHelper {
         WORKERS.get().schedule(describe(runnable, description), true, false, false);
     }
 
+    /**
+     * @deprecated not in use
+     */
+    @Deprecated
     public static void scheduleLast(Runnable runnable, String description) {
         WORKERS.get().schedule(describe(runnable, description), false, false, false);
     }
@@ -91,9 +98,9 @@ public final class ReactiveHelper {
 
     private static class Worker {
 
-        LinkedList<Runnable> queue = new LinkedList<>();
-        LinkedList<LinkedList<Runnable>> back;
-        boolean running;
+        private volatile LinkedList<Runnable> queue = new LinkedList<>();
+        private volatile LinkedList<LinkedList<Runnable>> back;
+        private volatile boolean running;
 
         public void schedule(Runnable runnable, boolean first, boolean main, boolean sync) {
             if (main) {
@@ -129,7 +136,7 @@ public final class ReactiveHelper {
 //                            thread.setName(name + " - " + polled.toString());
                             polled.run();
                         } catch (Throwable t) {
-                            t.printStackTrace();
+                            LOG.warn("Error executing reactive work due to " + t.getMessage() + ". This exception is ignored.", t);
                         }
                     }
                 } finally {
@@ -152,7 +159,8 @@ public final class ReactiveHelper {
                 thread.setName(name + " - " + polled.toString());
                 polled.run();
             } catch (Throwable t) {
-                t.printStackTrace();
+                // should not happen
+                LOG.warn("Error executing reactive work due to " + t.getMessage() + ". This exception is ignored.", t);
             } finally {
                 thread.setName(name);
             }