You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/12/24 07:42:13 UTC

[camel] branch master updated: CAMEL-14329: Adding component should not autowire singleton from registry in nested mode

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 da967a2  CAMEL-14329: Adding component should not autowire singleton from registry in nested mode
da967a2 is described below

commit da967a2093c24b34a3da73dc707bfb1c187e2249
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Dec 24 08:00:57 2019 +0100

    CAMEL-14329: Adding component should not autowire singleton from registry in nested mode
---
 .../PropertyBindingSupportAutowireNestedTest.java      | 18 ++++++++++++++++++
 .../apache/camel/support/PropertyBindingSupport.java   |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/support/PropertyBindingSupportAutowireNestedTest.java b/core/camel-core/src/test/java/org/apache/camel/support/PropertyBindingSupportAutowireNestedTest.java
index 95676f7..da8b082 100644
--- a/core/camel-core/src/test/java/org/apache/camel/support/PropertyBindingSupportAutowireNestedTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/support/PropertyBindingSupportAutowireNestedTest.java
@@ -51,6 +51,24 @@ public class PropertyBindingSupportAutowireNestedTest extends ContextTestSupport
         assertEquals(33, foo.getBar().getAge());
         assertTrue(foo.getBar().isRider());
         assertTrue(foo.getBar().isGoldCustomer());
+        // should not be auto wired
+        assertNull(foo.getBar().getWork());
+    }
+
+    @Test
+    public void testAutowirePropertiesNested() throws Exception {
+        Foo foo = new Foo();
+
+        PropertyBindingSupport.build().bind(context, foo, "name", "James");
+        PropertyBindingSupport.build().bind(context, foo, "bar.age", "33");
+        PropertyBindingSupport.build().bind(context, foo, "bar.rider", "true");
+        PropertyBindingSupport.build().bind(context, foo, "bar.gold-customer", "true");
+        PropertyBindingSupport.autowireSingletonPropertiesFromRegistry(context, foo, false, true, null);
+
+        assertEquals("James", foo.getName());
+        assertEquals(33, foo.getBar().getAge());
+        assertTrue(foo.getBar().isRider());
+        assertTrue(foo.getBar().isGoldCustomer());
         // should be auto wired
         assertNotNull(foo.getBar().getWork());
         assertEquals(456, foo.getBar().getWork().getId());
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
index 1a09199..4a7aca2 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
@@ -409,7 +409,7 @@ public final class PropertyBindingSupport {
                             }
                         }
                     }
-                } else if (value != null) {
+                } else if (value != null && deepNesting) {
                     // remember this as parent and also autowire nested properties
                     // do not walk down if it point to our-selves (circular reference)
                     parents.add(target);