Details
Description
I'm loading a xml routetemplate as resource as follows:
loader = extendedCamelContext.getRoutesLoader(); Resource resource = IntegrationUtil.setResource(routetemplate); log.info("Loading routetemplate " + routetemplate); try{ loader.loadRoutes(resource); }catch(java.lang.IllegalArgumentException e){ loader.updateRoutes(resource); }
I however made a mistake and the resource was empty. The error message/stacktrace I received was:
Unable to parse resource: route.yaml at org.apache.camel.dsl.yaml.YamlRoutesBuilderLoaderSupport.lambda$doLoadRouteBuilder$1(YamlRoutesBuilderLoaderSupport.java:90) at java.base/java.util.Optional.orElseThrow(Optional.java:408) at org.apache.camel.dsl.yaml.YamlRoutesBuilderLoaderSupport.doLoadRouteBuilder(YamlRoutesBuilderLoaderSupport.java:90) at org.apache.camel.dsl.support.RouteBuilderLoaderSupport.loadRoutesBuilder(RouteBuilderLoaderSupport.java:104) at org.apache.camel.impl.engine.DefaultRoutesLoader.findRoutesBuilders(DefaultRoutesLoader.java:124) at org.apache.camel.spi.RoutesLoader.findRoutesBuilders(RoutesLoader.java:117) at org.apache.camel.spi.RoutesLoader.loadRoutes(RoutesLoader.java:72)
I was a bit puzzled about this because I was thinking I was providing a XML. Maybe better in this case:
Unable to parse resource: empty resource
The text also mentions 'route', but it can also be a routeConfiguration or a routeTemplate.
Three sidenotes (some things I noticed):
1. In general one could check faulty input better. (is it a valid xml, yaml etc, or just some random text, empty or null). And for routetemplate are all the template parameters provide?
2. Notice in the example code I first need to create a resource before passing it to the routeloader. I have a string and would like to pass directly as a String to the routeloader.
3. When loading an existing route the routeloader may give an error (for example when the route already exist). I would like to loadOrUpdateRoute(String route) (this was possible in Camel 2).