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

Simple language produces null for a method call on a header value

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • 2.14.0
    • None
    • camel-core
    • None
    • Unknown

    Description

      Please could you confirm if this is a bug.

      It works if the text is sent in the body but not if it is sent in a header.

      I hope the test case is self explanatory.

      -------

      import org.apache.camel.CamelContext;
      import org.apache.camel.builder.RouteBuilder;
      import org.apache.camel.component.mock.MockEndpoint;
      import org.apache.camel.impl.DefaultCamelContext;

      public class CamelBug {

      public static void main(String[] args) throws Exception {
      CamelContext camelContext = new DefaultCamelContext();
      camelContext.addRoutes(new RouteBuilder() {
      @Override
      public void configure() throws Exception

      { from("direct:test"). //setBody(simple("body.replace('a','b')")). setBody(simple("header[text].replace('a','b')")). to("mock:test"); }

      });
      camelContext.start();
      camelContext.createProducerTemplate().sendBodyAndHeader("direct:test","","text","replace me");
      MockEndpoint mockEndpoint =
      camelContext.getEndpoint("mock:test", MockEndpoint.class);
      String replacedMessage =
      mockEndpoint.getExchanges().get(0).getIn().getBody(String.class);

      System.out.println(replacedMessage);//gives null
      //assertEquals("replbce me", replacedMessage);
      }

      }

      Attachments

        Activity

          People

            njiang Willem Jiang
            hazlorealidad Andy Bailey
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: