[ 
https://issues.apache.org/jira/browse/WICKET-7071?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17762759#comment-17762759
 ] 

Martin Tzvetanov Grigorov commented on WICKET-7071:
---------------------------------------------------

Debugged the problem with embedded Jetty.

It appears that jakarta.servlet.ServletRequest#getParameterMap() would read the 
parameters only if there was no call to 
jakarta.servlet.ServletRequest#getInputStream and/or 
jakarta.servlet.ServletRequest#getReader()

 

!wicket-7071-first-getInputStream.png!

Above you can see that Request._inputState changes from 0 (initial) to 1 
(inputStream).

 

!wicket-7071-getParameters.png!

And here you can see that when Wicket calls #getParameterMap() would populate 
the Map only if the Request state is 0 (initial), but does nothing for 1 
(inputStream) and 2 (reader).

 

[https://jakarta.ee/specifications/servlet/6.0/jakarta-servlet-spec-6.0#when-parameters-are-available]
 does not explain why it behaves like that. You may want to check with the 
Jetty (or Tomcat) team for more information.

> Problems when calling request.getInputStream() before executing WicketFilter
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-7071
>                 URL: https://issues.apache.org/jira/browse/WICKET-7071
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-core
>    Affects Versions: 10.0.0-M1, 9.14.0
>         Environment: Java 17 or 21-ea; Jetty 11 or Tomcat 10.1.x; Wicket 
> 10.0.0-M1 or 9.3+.
>            Reporter: Sam Peters
>            Priority: Major
>             Fix For: 9.15.0, 10.0.0-M2
>
>         Attachments: wicket-7071-first-getInputStream.png, 
> wicket-7071-getParameters.png
>
>
> Calling request.getInputStream() (without reading any data from the stream), 
> followed by a WicketFilter, causes certain wicket requests to fail.
> If no call to request.getInputStream() is made, everything works as expected.
> See runnable, minimal Maven project here: 
> [https://github.com/gluser1357/jerseyissues/tree/issue-4867-wicket10|https://github.com/gluser1357/jerseyissues/tree/issue-4867-wicket10]
>  > readme.txt.
> The issue is always reproducable e. g. in Jetty 11 and Tomcat 10.1.x (Jakarta 
> Servlet 5+).
> A use case for the described filter combination is e. g. to add an existing 
> Jersey-based authorization filter in front of a Wicket application. Since 
> Jersey calls at some point request.getInputStream(), our Wicket application 
> fails at then. See more details on this here: 
> [https://github.com/eclipse-ee4j/jersey/issues/4867|https://github.com/eclipse-ee4j/jersey/issues/4867]
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to