Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-910

Content type is not properly set for null or empty parameters

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • None
    • 2.3.5.Final, 2.3.6.Final
    • jaxrs
    • None

    Description

      I've created a RESTEasy client for a service:

      @PUT
      @Path("/order/{orderNumber}/ship")
      void setStatusToShipped(@PathParam("orderNumber") long orderNumber, @Form ExternalTrackAndTraceDTO trackAndTrace)
      

      Making the calls

      service.setStatusToShipped(1, null);
      

      and

      service.setStatusToShipped(1, new ExternalTrackAndTraceDTO());
      

      trigger this exception:

      java.lang.IllegalArgumentException: Request media type is not application/x-www-form-urlencoded
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletInputMessage.getPutFormParameters(HttpServletInputMessage.java:81)
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletInputMessage.getFormParameters(HttpServletInputMessage.java:116)
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletInputMessage.getPutDecodedFormParameters(HttpServletInputMessage.java:89)
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletInputMessage.getDecodedFormParameters(HttpServletInputMessage.java:135)
      	at org.jboss.resteasy.core.FormParamInjector.inject(FormParamInjector.java:32)
      	at org.jboss.resteasy.core.PropertyInjectorImpl.inject(PropertyInjectorImpl.java:209)
      	at org.jboss.resteasy.core.FormInjector.inject(FormInjector.java:48)
      	at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:136)
      

      The problem seems to be in org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor, line 323, as that's where the content type is set.
      Since null parameters or parameters without any values inside don't add any form params, the proper content type is not being set.

      Probably another way of checking if the content type header needs to be added should be done.

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            andrei.ivanov@gmail.com Andrei Ivanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: