This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 a3f24de CAMEL-15801: Restrict DefaultConfigurerResolver fallback
resolution (#4559)
a3f24de is described below
commit a3f24dea3a45c151e53267386033678e54729f0d
Author: Marco Collovati <[email protected]>
AuthorDate: Tue Nov 3 21:56:55 2020 +0100
CAMEL-15801: Restrict DefaultConfigurerResolver fallback resolution (#4559)
DefaultConfigurerResolver fallbacks to ExtendedCamelContext FQCN
for names containing "CamelContext".
This change restricts fallback mechanims checking also that name
starts with "org.apache.camel".
---
.../impl/engine/DefaultConfigurerResolver.java | 2 +-
.../impl/engine/DefaultConfigurerResolverTest.java | 50 ++++++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletion(-)
diff --git
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultConfigurerResolver.java
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultConfigurerResolver.java
index b356876..8b774f2 100644
---
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultConfigurerResolver.java
+++
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultConfigurerResolver.java
@@ -68,7 +68,7 @@ public class DefaultConfigurerResolver implements
ConfigurerResolver {
try {
type = findConfigurer(name, context);
if (type == null) {
- if (name.contains("CamelContext")) {
+ if (name.startsWith("org.apache.camel.") &&
name.contains("CamelContext")) {
// fallback special for camel context itself as we have an
extended configurer
type =
findConfigurer(ExtendedCamelContext.class.getName(), context);
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/impl/engine/DefaultConfigurerResolverTest.java
b/core/camel-core/src/test/java/org/apache/camel/impl/engine/DefaultConfigurerResolverTest.java
new file mode 100644
index 0000000..a4ba3d9
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/impl/engine/DefaultConfigurerResolverTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.impl.engine;
+
+import java.util.stream.Stream;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.ExtendedCamelContextConfigurer;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class DefaultConfigurerResolverTest {
+
+ private DefaultConfigurerResolver resolver;
+
+ @Test
+ void
resolvePropertyConfigurerShouldFallbackToExtendedCamelContextOnlyForCamelComponents()
{
+ resolver = new DefaultConfigurerResolver();
+ DefaultCamelContext ctx = new DefaultCamelContext();
+
+ Stream.of(CamelContext.class.getName(),
ExtendedCamelContext.class.getName(),
+ SimpleCamelContext.class.getName(),
"org.apache.camel.SomeCamelContextStuff")
+ .forEach(name ->
assertThat(resolver.resolvePropertyConfigurer(name, ctx))
+
.as(name).isInstanceOf(ExtendedCamelContextConfigurer.class));
+
+ Stream.of(
+ "CamelContext", "ExtendedCamelContext", "SimpleCamelContext",
+ "org.somepackage.CamelContext",
"it.apache.camel.ExtendedCamelContext")
+ .forEach(name ->
assertThat(resolver.resolvePropertyConfigurer(name, ctx)).as(name).isNull());
+
+ }
+
+}