You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/07/22 09:39:42 UTC

[camel] branch master updated: CAMEL-15283: Ensure managed vertx instances are closed on shutdown (#4030)

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

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 48dd142  CAMEL-15283: Ensure managed vertx instances are closed on shutdown (#4030)
48dd142 is described below

commit 48dd142ee724046e2fd5d0ce09964855a10d2803
Author: James Netherton <ja...@users.noreply.github.com>
AuthorDate: Wed Jul 22 10:39:30 2020 +0100

    CAMEL-15283: Ensure managed vertx instances are closed on shutdown (#4030)
---
 .../camel/component/vertx/http/VertxHttpComponent.java       | 12 ++++++++++++
 .../apache/camel/component/vertx/http/VertxHttpEndpoint.java |  6 ++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/components/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpComponent.java b/components/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpComponent.java
index 31d4f22..353f53b 100644
--- a/components/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpComponent.java
+++ b/components/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpComponent.java
@@ -53,6 +53,7 @@ public class VertxHttpComponent extends HeaderFilterStrategyComponent implements
     private boolean useGlobalSslContextParameters;
     @Metadata(label = "advanced")
     private boolean allowJavaSerializedObject;
+    private boolean managedVertx;
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
@@ -147,6 +148,16 @@ public class VertxHttpComponent extends HeaderFilterStrategyComponent implements
         return endpoint.createProducer();
     }
 
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+
+        if (managedVertx && vertx != null) {
+            vertx.close();
+        }
+        vertx = null;
+    }
+
     public Vertx getVertx() {
         if (vertx == null) {
             Set<Vertx> vertxes = getCamelContext().getRegistry().findByType(Vertx.class);
@@ -161,6 +172,7 @@ public class VertxHttpComponent extends HeaderFilterStrategyComponent implements
             } else {
                 vertx = Vertx.vertx();
             }
+            managedVertx = true;
         }
 
         return vertx;
diff --git a/components/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpEndpoint.java b/components/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpEndpoint.java
index 073b546..3d1e46f 100644
--- a/components/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpEndpoint.java
+++ b/components/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpEndpoint.java
@@ -88,8 +88,10 @@ public class VertxHttpEndpoint extends DefaultEndpoint {
     @Override
     protected void doStop() throws Exception {
         super.doStop();
-        webClient.close();
-        webClient = null;
+        if (webClient != null) {
+            webClient.close();
+            webClient = null;
+        }
     }
 
     @Override