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

Response body lost when an HTTP error code is returned

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.6.0, 2.7.0, 2.8.0
    • 2.8.2, 2.9.0
    • camel-restlet
    • None
    • Novice

    Description

      When a REST service returns an HTTP error code (e.g. 404) with some content in the response body, this body is not correctly copied into the exception.
      This results e.g. in ${exception.responseBody} having a value like "org.restlet.data.Response@17bf0a7" in the following route fragment :

      <doTry>
      <to uri="restlet:http://my.service.com/ws/

      {id}

      "/>
      <doCatch>
      <exception>org.apache.camel.CamelException</exception>
      <log message="body is : ${exception.responseBody}"/>
      </doCatch>
      </doTry>

      The problem is probably due to the statement (class org.apache.camel.component.restlet.RestletProducer, method populateRestletProducerException) :

         String copy = response.toString();
      

      that should be instead something like :

         String copy = null;
         if (response.getEntity() != null) {
             // get content text
             copy = response.getEntity().getText();
         }
      

      Attachments

        Activity

          People

            njiang Willem Jiang
            cedric.delaunois Cedric de Launois
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: