gnodet-bot commented on code in PR #30453:
URL: https://github.com/apache/camel/pull/30453#discussion_r4635143769
##########
components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletProducer.java:
##########
@@ -126,6 +148,55 @@ public boolean process(Exchange exchange, AsyncCallback
originalCallback) {
}
}
+ /**
+ * The output data type of the source Kamelet whose route the exchange is
in, from the route property that the
+ * Kamelet YAML loader sets, or null when it has none. The outcome is
looked up once and kept.
+ */
+ private Processor sourceOutputType(Exchange exchange) {
+ if (!sourceOutputTypeResolved) {
+ synchronized (this) {
+ if (!sourceOutputTypeResolved) {
+ Route route = ExchangeHelper.getRoute(exchange);
+ Object type = route != null ?
route.getProperties().get(Kamelet.SOURCE_OUTPUT_TYPE_PROPERTY) : null;
+ if (type != null) {
+ sourceOutputType = createSourceOutputType(route,
type.toString());
+ }
+ sourceOutputTypeResolved = true;
+ }
+ }
+ }
+ return sourceOutputType;
+ }
+
+ private Processor createSourceOutputType(Route route, String type) {
+ DataTypeProcessor processor = new DataTypeProcessor(null, type);
+ processor.setCamelContext(getEndpoint().getCamelContext());
+ try {
+ ServiceHelper.startService(processor);
+ return processor;
+ } catch (Exception e) {
Review Comment:
`catch (Exception e)` catches more than the expected
`IllegalArgumentException` from `DataTypeProcessor.doInit()`. An unexpected
`NullPointerException` or misconfiguration would silently fall into the
`TypeConverterTransformer` fallback instead of propagating.
```suggestion
} catch (IllegalArgumentException e) {
```
--
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]