camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lburgazz...@apache.org
Subject camel git commit: CAMEL-11537: undertown consumer : consumer silently fails to start if manually started after a failure
Date Wed, 12 Jul 2017 14:07:38 GMT
Repository: camel
Updated Branches:
  refs/heads/master 8f7b5e366 -> fb0ab0e96


CAMEL-11537: undertown consumer : consumer silently fails to start if manually started after
a failure


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fb0ab0e9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fb0ab0e9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fb0ab0e9

Branch: refs/heads/master
Commit: fb0ab0e961985806d327746683997c8acd2c5dbc
Parents: 8f7b5e3
Author: lburgazzoli <lburgazzoli@gmail.com>
Authored: Wed Jul 12 16:07:12 2017 +0200
Committer: lburgazzoli <lburgazzoli@gmail.com>
Committed: Wed Jul 12 16:07:12 2017 +0200

----------------------------------------------------------------------
 .../component/undertow/DefaultUndertowHost.java  | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fb0ab0e9/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHost.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHost.java
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHost.java
index 88ef8a1..89447ef 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHost.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHost.java
@@ -80,7 +80,24 @@ public class DefaultUndertowHost implements UndertowHost {
 
             undertow = builder.setHandler(rootHandler).build();
             LOG.info("Starting Undertow server on {}://{}:{}", key.getSslContext() != null
? "https" : "http", key.getHost(), key.getPort());
-            undertow.start();
+
+            try {
+                // If there is an exception while starting up, Undertow wraps it
+                // as RuntimeException which leaves the consumer in an inconsistent
+                // state as a subsequent start if the route (i.e. manually) won't
+                // start the Undertow instance as undertow is not null.
+                undertow.start();
+            } catch (RuntimeException e) {
+                LOG.warn("Failed to start Undertow server on {}://{}:{}, reason: {}", key.getSslContext()
!= null ? "https" : "http", key.getHost(), key.getPort(), e.getMessage());
+
+                // Cleanup any resource that may have been created during start
+                // and reset the instance so a subsequent start will trigger the
+                // initialization again.
+                undertow.stop();
+                undertow = null;
+
+                throw e;
+            }
         }
 
         String path = registrationInfo.getUri().getPath();


Mime
View raw message