eclipse-ee4j / jersey

Eclipse Jersey Project - Read our Wiki:
https://github.com/eclipse-ee4j/jersey/wiki
Other
689 stars 351 forks source link

WebComponent.filterFormParameters reports confusing error for @GET method #3243

Open jerseyrobot opened 8 years ago

jerseyrobot commented 8 years ago

We have a @GET rest method that accepts parameter named "list[]":

@GET
    @Path("/listvalues")
    public Map<String, Object> listGlobalParametersValues(@DefaultValue("") @QueryParam("name[]") List<String> names) {
        log.trace("listGlobalParametersValues: {}", names);

        return service.listValues(names);
    }

When I request this method with AJAX and content type is javax.ws.rs.core.MediaType#APPLICATION_FORM_URLENCODED_TYPE the request generates the following error:

WARNING: A servlet request to the URI http://localhost:8080/api/x/listvalues?name%5B%5D=VALUATION_DATE contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.

However, I can't sue tt>@FormParam</tt, because it is tt>@GET</tt method - and Jersey wouldn't start at all. The whole part "...the request body has been consumed by the servlet or a servlet filter accessing the request parameters" is rather confusing - what request body? There is no request body in my case (that is - there is nothing after headers). If I don't use that content-type, it is OK.

But the content-type seems to be allowed for GET. Shouldn't there be some junction for GET requests to avoid the warning?

Affected Versions

[2.21]

jerseyrobot commented 6 years ago
jerseyrobot commented 8 years ago

@glassfishrobot Commented Reported by virgo47

jerseyrobot commented 8 years ago

@glassfishrobot Commented virgo47 said: Forgot to mention, that the method works OK, parameters are processed without any problem, so it makes the warning kinda superfluous, because obviously it works "as expected".

jerseyrobot commented 8 years ago

@glassfishrobot Commented mattbishop said: What was the reason for adding this WARN message? I have valid reasons to check the form params in a servlet filter long before Jersey gets the request. I don't see any way of turning this message off too.

jerseyrobot commented 8 years ago

@glassfishrobot Commented @mpotociar said: Obviously seems like a confusing message in our Servlet container integration code in this particular case.

jerseyrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA JERSEY-2971