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

jamesnetherton pushed a commit to branch 3.20.x
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/3.20.x by this push:
     new 662641df84 Add type check for non-synthetic beans in 
RuntimeBeanRepository.getReferenceByName
662641df84 is described below

commit 662641df84bc90a196508f979cf10503a88a4d85
Author: James Netherton <[email protected]>
AuthorDate: Tue Sep 2 13:56:23 2025 +0100

    Add type check for non-synthetic beans in 
RuntimeBeanRepository.getReferenceByName
    
    Fixes #7680
---
 .../java/org/apache/camel/quarkus/core/runtime/CamelRegistryTest.java | 3 +++
 .../java/org/apache/camel/quarkus/core/RuntimeBeanRepository.java     | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/runtime/CamelRegistryTest.java
 
b/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/runtime/CamelRegistryTest.java
index 02c691f2e7..7defc1b9d7 100644
--- 
a/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/runtime/CamelRegistryTest.java
+++ 
b/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/runtime/CamelRegistryTest.java
@@ -82,6 +82,9 @@ public class CamelRegistryTest {
         assertThat(registry.findByTypeWithName(String.class))
                 .containsEntry("bean-1", "a")
                 .containsEntry("bean-2", "b");
+
+        // Incorrect type lookup should return null
+        assertThat(registry.lookupByNameAndType("bean-1", 
Integer.class)).isNull();
     }
 
     @ApplicationScoped
diff --git 
a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeBeanRepository.java
 
b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeBeanRepository.java
index ad0e568118..06531cfcc1 100644
--- 
a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeBeanRepository.java
+++ 
b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeBeanRepository.java
@@ -157,7 +157,9 @@ public final class RuntimeBeanRepository implements 
BeanRepository {
                     result = instance.get();
                 }
             } else {
-                result = instance.get();
+                if (type.isInstance(instance.get())) {
+                    result = instance.get();
+                }
             }
         }
 

Reply via email to