Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-10402

Request @RequestParam not enforced with empty values

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 3.2.2
    • Fix Version/s: 3.2.3, 4.0 M1
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      I have defined this method signature:

      @RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_XML_VALUE,
        "application/json;charset=UTF-8" })
      public ResponseEntity<Object> searchProjects(@RequestParam(value = "q") String query,
        @RequestParam("attributes") String[] attributes,
        @RequestParam(value = "outputType", required = false, defaultValue = "hash") OutputType outputType)
        throws MissingServletRequestParameterException
      

      When I invoke this method either with:

      GET /rest?q&attributes=one
      

      or

      GET /rest?q=&attributes=one
      

      The query variable is always passed as empty string/null although its defined as required. MissingServletRequestParameterException is not thrown.

      I have attached a screenshot of the debugging session where one can inspect that case. I think the else if in lines 95 to 97 are incomplete.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rstoya05-aop Rossen Stoyanchev
                Reporter:
                michael-o Michael Osipov
                Last updater:
                Stefan Gheorghiu
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  4 years, 40 weeks, 6 days ago