jamesnetherton commented on code in PR #6304:
URL: https://github.com/apache/camel-quarkus/pull/6304#discussion_r1697970099
##########
extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeBeanRepository.java:
##########
@@ -163,8 +165,13 @@ public <T> T findSingleByType(Class<T> type) {
} else {
handles = container.listAll(type);
}
+
if (handles.size() > 0) {
- return handles.get(0).get();
+ if (handles.stream().filter(h ->
!h.getBean().getKind().equals(InjectableBean.Kind.SYNTHETIC)).count() > 0) {
Review Comment:
What's the significance of the `SYNTHETIC` beans kind where we can just take
the first one? Is that safe if multiple results are returned?
##########
extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/RuntimeBeanRepository.java:
##########
@@ -163,8 +165,13 @@ public <T> T findSingleByType(Class<T> type) {
} else {
handles = container.listAll(type);
}
+
if (handles.size() > 0) {
- return handles.get(0).get();
+ if (handles.stream().filter(h ->
!h.getBean().getKind().equals(InjectableBean.Kind.SYNTHETIC)).count() > 0) {
+ return handles.get(0).get();
+ } else {
+ return container.select(type,
Default.Literal.INSTANCE).get();
Review Comment:
Is it safe to call `get()` if no default bean exists? IIRC it'll throw an
exception if not.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]