This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-3.14.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.14.x by this push: new 7da4a11f7e8 CAMEL-18331: Endpoint bean added via beans.xml are parsed twice (#8096) 7da4a11f7e8 is described below commit 7da4a11f7e830434ccc9d3b17537ec2e03f5fff6 Author: Luigi De Masi <5583341+luigidem...@users.noreply.github.com> AuthorDate: Wed Aug 3 06:18:38 2022 +0200 CAMEL-18331: Endpoint bean added via beans.xml are parsed twice (#8096) --- .../spring/xml/handler/CamelNamespaceHandler.java | 3 +- .../spring/SpringEndpointRegistrationTest.java | 43 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/components/camel-spring-xml/src/main/java/org/apache/camel/spring/xml/handler/CamelNamespaceHandler.java b/components/camel-spring-xml/src/main/java/org/apache/camel/spring/xml/handler/CamelNamespaceHandler.java index 13268bd307f..4f66e8bcba4 100644 --- a/components/camel-spring-xml/src/main/java/org/apache/camel/spring/xml/handler/CamelNamespaceHandler.java +++ b/components/camel-spring-xml/src/main/java/org/apache/camel/spring/xml/handler/CamelNamespaceHandler.java @@ -739,8 +739,7 @@ public class CamelNamespaceHandler extends NamespaceHandlerSupport { } catch (Exception e) { // Do nothing here } - parserContext.registerBeanComponent(new BeanComponentDefinition(definition, id)); + parserContext.registerComponent(new BeanComponentDefinition(definition, id)); } } - } diff --git a/components/camel-spring-xml/src/test/java/org/apache/camel/spring/SpringEndpointRegistrationTest.java b/components/camel-spring-xml/src/test/java/org/apache/camel/spring/SpringEndpointRegistrationTest.java new file mode 100644 index 00000000000..8fb6504a9e1 --- /dev/null +++ b/components/camel-spring-xml/src/test/java/org/apache/camel/spring/SpringEndpointRegistrationTest.java @@ -0,0 +1,43 @@ +/* + * 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.spring; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class SpringEndpointRegistrationTest extends SpringEndpointPropertyTest { + + /** + * This test fail during initialization if a bean is registered twice with the same id This is for CAMEL-18331 + */ + + @Override + protected AbstractXmlApplicationContext createApplicationContext() { + return new NoRebindClassPathXmlApplicationContext("org/apache/camel/spring/SpringEndpointPropertyTest.xml"); + } + + class NoRebindClassPathXmlApplicationContext extends ClassPathXmlApplicationContext { + public NoRebindClassPathXmlApplicationContext(String configLocation) throws BeansException { + super((ApplicationContext) null); + this.setAllowBeanDefinitionOverriding(false); + this.setConfigLocations(new String[] { configLocation }); + this.refresh(); + } + } +}