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

Exceptions thrown from converters are not correctly handled

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.5.0
    • 1.6.0, 2.0-M1
    • camel-core
    • None

    Description

      Related nabble: http://www.nabble.com/Handling-converter-failure-td20830148s22882.html

      When an exception is thrown from a @Converter it is not correctly handled by onException. The handler is receiving a RuntimeCamelException and not checking the cause when determining the best handler.

      /////Converter
      @Converter
      public static LocalDateTime toLocalDateTime(final Object localDateTime)
      {
        System.out.println("Converting to local date time");
        throw new IllegalArgumentException("Bad data");
      }
      
      /////Routes
      Routes routes = new RouteBuilder() {
      
        @Override
        public void configure() throws Exception {
          onException(IllegalArgumentException.class).handled(true).to("mock:exception");
          from("direct:test").convertBodyTo(LocalDateTime.class).to("mock:end");
        }
      };
      
      
      /////Test
      MockEndpoint endpoint = (MockEndpoint)
      camelContext.getEndpoint("mock:end");
      endpoint.expectedMessageCount(0);
      MockEndpoint endpoint2 = (MockEndpoint)
      camelContext.getEndpoint("mock:exception");
      endpoint2.expectedMessageCount(1);
      
      camelContext.createProducerTemplate().sendBody("direct:test", "test");
      
      endpoint.assertIsSatisfied();
      endpoint2.assertIsSatisfied();
      
      

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            pledge Martin Gilday
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: