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

NullPointerException when an http request parameter value contains invalid characters (URISyntaxException)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.2.RC1
    • 2.1.0.GA
    • None
    • None
    • Hide

      1)deploy a REST service that accepts GET requests and evaluates an http parameter, e.g.:
      @GET
      @Path("/service")
      public Response service(@PathParam("query-string") String queryString);

      2)send a request with one or more invalid characters in the http parameter, e.g.:
      http://..../service?query-string=1|2}

      Show
      1)deploy a REST service that accepts GET requests and evaluates an http parameter, e.g.: @GET @Path("/service") public Response service(@PathParam("query-string") String queryString); 2)send a request with one or more invalid characters in the http parameter, e.g.: http://..../service?query-string=1 |2}

      Test case:
      an HTTP Request contains invalid characters in the value of an expected http parameter, for example:
      http://....?parameter=},xyz{|i

      Effect:
      The correct response code should be just a simple 400 Bad Request but on the other hand RESTEasy returns an HTTP Status 500 response with a NullPointerException stacktrace in the response body.
      From the error logs it is visible that the NullPointerException is being caused by URI creation failing:

      24/02/11 16:28:45:045 [ERROR] [[localhost].[/].[Resteasy]] Servlet.service() for servlet Resteasy threw exception
      java.lang.NullPointerException
      at org.jboss.resteasy.plugins.server.servlet.HttpServletInputMessage.<init>(HttpServletInputMessage.java:60)
      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.createHttpRequest(HttpServletDispatcher.java:237)
      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:189)
      ...
      ...
      at java.net.URI$Parser.fail(URI.java:2809)
      at java.net.URI$Parser.checkChars(URI.java:2982)
      at java.net.URI$Parser.parseHierarchical(URI.java:3072)
      at java.net.URI$Parser.parse(URI.java:3014)
      at java.net.URI.<init>(URI.java:578)
      at java.net.URI.create(URI.java:840)
      ... 26 more

              patriot1burke@gmail.com Bill Burke (Inactive)
              bennyfio_jira Benedetto Fiorelli (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: