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

camel-rest - Client request validation and empty body

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 4.8.0
    • 4.8.1, 4.9.0
    • came-core
    • None
    • Unknown

    Description

      If you enable the client request validation at a global level, and have a GET rest endpoint, there is no need for a body validation.

      The problem is if the client sends the Content-type aplication/json. The Content-Type is not needed tbut I got the issue because a client sends this header all the time and I can't change it.

      I faced the issue while upgrading an application from 3.20.6 to 4.8.0. I

      Here are curl examples:

      # succeeds
      $ curl localhost:8080/api/hello
      {"message":"hello world"}
      
      # fails
      $ curl -H "Content-Type: application/json" localhost:8080/api/hello
      Invalid JSon payload.

       

      In the problematic case, the DefaultRestClientRequestValidator will try to deserialize the json against an empty string and will fail because it's not a valid json.

       

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            foobarqix Olivier Jacquemart
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: