Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
4.3.0
-
None
-
Unknown
Description
Some time ago a new property was added to Apache Camel in CAMEL-10421, called "includeNonSingletons". It was configured via "camel.springboot.includeNonSingletons" property. Now it looks like `org.apache.camel.main.DefaultRoutesCollector.collectRoutesFromRegistry` finds all RouteBuilder in its `findByType(camelContext, RoutesBuilder.class);` method, regardless of whether they're prototypes or not by calling Spring's .`org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(@Nullable Class<T> type)`, which hard-codes `includeNonSingletons` to `true`.
In older Camel versions `org.apache.camel.spring.boot.RoutesCollector` class would run method `onApplicationEvent` and it would not touch prototypes due to this: "applicationContext.getBeansOfType(RoutesBuilder.class, configurationProperties.isIncludeNonSingletons(), true).values()".
This issue causes our code to fail because we have a RouteBuilder prototype with only constructor to set URI and routeId dynamically for each builder. But we don't need Camel to do it automatically, because it does not know what to pass to that constructor.