This is an automated email from the ASF dual-hosted git repository. lburgazzoli 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 6cc53d7 Undertow does not shut down properly in webhook route policy 6cc53d7 is described below commit 6cc53d7d3a3ae85df8fa1b7de16498bb3f97e096 Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Mon Oct 28 14:33:11 2019 +0100 Undertow does not shut down properly in webhook route policy --- .../component/undertow/UndertowComponent.java | 10 +++++- .../undertow/UndertowNoAutoStartupTest.java | 37 ++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java index 7468b7e..de7b3f4 100644 --- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java +++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java @@ -337,6 +337,7 @@ public class UndertowComponent extends DefaultComponent implements RestConsumerF host.validateEndpointURI(uri); handlers.add(registrationInfo); + return host.registerHandler(registrationInfo, handler); } @@ -344,8 +345,15 @@ public class UndertowComponent extends DefaultComponent implements RestConsumerF final URI uri = registrationInfo.getUri(); final UndertowHostKey key = new UndertowHostKey(uri.getHost(), uri.getPort(), sslContext); final UndertowHost host = undertowRegistry.get(key); + handlers.remove(registrationInfo); - host.unregisterHandler(registrationInfo); + + // if the route is not automatically started, then the undertow registry + // may not have any instance of UndertowHost associated to the given + // registrationInfo + if (host != null) { + host.unregisterHandler(registrationInfo); + } } protected UndertowHost createUndertowHost(UndertowHostKey key) { diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowNoAutoStartupTest.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowNoAutoStartupTest.java new file mode 100644 index 0000000..2ab3b0b --- /dev/null +++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowNoAutoStartupTest.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.undertow; + +import org.apache.camel.builder.RouteBuilder; +import org.junit.Test; + +public class UndertowNoAutoStartupTest extends BaseUndertowTest { + @Test + public void testUndertow() throws Exception { + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + public void configure() { + from("undertow:http://localhost:{{port}}/myapp") + .autoStartup(false) + .to("mock:myapp"); + } + }; + } +}