Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-16821

camel-bean - BeanProcessor with Process bean does not handle Throwable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.11.0
    • 3.11.1, 3.12.0
    • camel-bean
    • None
    • Unknown

    Description

      Invoking a Processor bean with BeanProcessor does not handle a non Exception Throwable thrown by the Processor, for example if the Processor throw an AssertionError. The throwable will be caught and logged by the DefaultReactiveExecutor above, but because it is ignored and prevented the execution of callbacks the route is stuck.

      With the following route:

      @Component
      public static class Route extends RouteBuilder {
      	@Override
      	public void configure() throws Exception {
      		from("direct:test")
      				.bean(Service.class);
      	}
      }
      
      @Component
      public static class Service implements Processor {
      	@Override
      	public void process(Exchange exchange) throws Exception {
      		throw new AssertionError("test");
      	}
      }
      
      @Component
      public static class Runner implements CommandLineRunner {
      
      	@Autowired
      	private CamelContext camelContext;
      
      	@Autowired
      	private ProducerTemplate producerTemplate;
      
      	@Override
      	public void run(String... args) throws Exception {
      		var exchange = new DefaultExchange(camelContext)
      		producerTemplate.send("direct:test", exchange);
      	}
      }
      

      The code will block indefinitely on the producerTemplate.send(...)

      This is not an issue when a method is invoked directly because the AssertionError is wrapped in an InvocationTargetException, it only occurs when a Processor is used.

      It look like a regression from this commit https://github.com/apache/camel/commit/ab217659e3c9013322a5e7793db5dff904dc4c67 that changed the catch Throwable in catch Exception when the processor is invoked in AbstractBeanProcessor.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            spadou Samuel Padou
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: