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

NullPointerException when decoding PUT form parameters without media type header

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.3.3.Final
    • 2.2.2.GA, 2.3.2.Final
    • jaxrs
    • None

      Making a PUT call without setting the Content-Type header triggers a NPE:

      java.lang.NullPointerException
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletInputMessage.getPutFormParameters(HttpServletInputMessage.java:67)
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletInputMessage.getFormParameters(HttpServletInputMessage.java:114)
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletInputMessage.getPutDecodedFormParameters(HttpServletInputMessage.java:88)
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletInputMessage.getDecodedFormParameters(HttpServletInputMessage.java:127)
      	at org.jboss.resteasy.core.FormParamInjector.inject(FormParamInjector.java:27)
      	at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:114)
      

      From what I see, the fix would be to modify org.jboss.resteasy.plugins.server.servlet.HttpServletInputMessage#getPutFormParameters():
      replace

      if (getHttpHeaders().getMediaType().isCompatible(MediaType.valueOf("application/x-www-form-urlencoded")))
      

      with

      if (MediaType.valueOf("application/x-www-form-urlencoded").isCompatible(getHttpHeaders().getMediaType()))
      

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

                Created:
                Updated:
                Resolved: