gnodet-bot commented on code in PR #27609:
URL: https://github.com/apache/camel/pull/27609#discussion_r4228070101
##########
core/camel-yaml-io/src/main/java/org/apache/camel/yaml/LwModelToYAMLDumper.java:
##########
@@ -267,6 +295,38 @@ public String dumpDataFormatsAsYaml(CamelContext context,
Map<String, Object> da
return buffer.toString();
}
+ /**
+ * Collects the context scoped onExceptions that were added to the outputs
of the route when it was prepared
+ */
+ private static void collectContextScopedOnExceptions(RouteDefinition
route, List<OnExceptionDefinition> answer) {
+ for (var output : route.getOutputs()) {
+ if (output instanceof OnExceptionDefinition oe &&
!oe.isRouteScoped() && !containsInstance(answer, oe)) {
+ answer.add(oe);
+ }
+ }
+ }
+
+ private static boolean isInRouteConfiguration(CamelContext context,
OnExceptionDefinition oe) {
+ Model model = context != null ?
context.getCamelContextExtension().getContextPlugin(Model.class) : null;
+ if (model != null) {
+ for (RouteConfigurationDefinition config :
model.getRouteConfigurationDefinitions()) {
+ if (containsInstance(config.getOnExceptions(), oe)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private static boolean containsInstance(List<?> list, Object instance) {
Review Comment:
💡 **Nit:** `containsInstance` will throw `NullPointerException` if `list` is
null. `config.getOnExceptions()` is normally non-null, but
`setOnExceptions(null)` makes it possible. Consistent with the defensive style
of `isInRouteConfiguration`:
```suggestion
private static boolean containsInstance(List<?> list, Object instance) {
if (list == null) {
return false;
}
for (Object o : list) {
if (o == instance) {
return true;
}
}
return false;
}
```
--
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]