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

camel-sql - body not copied from in to out when useing outputHeader and outputType=SelectOne when sql doesn't return a result

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.17.0
    • 2.16.4, 2.17.1, 2.18.0
    • camel-sql
    • None
    • Unknown

    Description

      When using the options outputHeader and outputType=SelectOne the body of the Exchange is not copied from in to out when the select returns no data..

      Probably root is line 175-185 of SqlProducer.java that is missing an else for the above mentioned case.

      if (data != null) { // <--- Missing the else
      // for noop=true we still want to enrich with the row count header
        if (getEndpoint().isNoop()) {
          exchange.getOut().setBody(exchange.getIn().getBody());
        } else if (getEndpoint().getOutputHeader() != null) {
          exchange.getOut().setBody(exchange.getIn().getBody());
          exchange.getOut().setHeader(getEndpoint().getOutputHeader(), data);
        } else {
          exchange.getOut().setBody(data); 
        }
        exchange.getOut().setHeader(SqlConstants.SQL_ROW_COUNT, 1);
      }
      

      following could be added (untested)

      else { // if data == null
      if (getEndpoint().isNoop()) {
                                              exchange.getOut().setBody(exchange.getIn().getBody());
                                          } else if (getEndpoint().getOutputHeader() != null) {
                                              exchange.getOut().setBody(exchange.getIn().getBody());
                                          }
       exchange.getOut().setHeader(SqlConstants.SQL_ROW_COUNT, 0);
      }
      

      Attachments

        1. CamelSqlComponentTest.java
          2 kB
          Thomas Bender
        2. db-camel-data.sql
          0.1 kB
          Thomas Bender
        3. db-camel-schema.sql
          0.1 kB
          Thomas Bender

        Activity

          People

            acosentino Andrea Cosentino
            Thomas.Bender@flatironssolutions.com Thomas Bender
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: