-
Notifications
You must be signed in to change notification settings - Fork 40.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ordering of WebMvcMetricsFilter
breaks character encoding
#11607
Comments
On top of addressing the ordering problem that leads to this issue, would it makes sense to introduce some sort of validation that checks whether Boot could have a test that verifies this, since it has happened a few time that other filters got in front of |
|
Should the |
Making |
@sriki77 of course. Particularly interested by a regression test for this. |
…bMvcMetricsFilter Made the OrderedCharacterEncodingFilter implement PriorityOrdered Changed the WebMvcMetricsFilter to implement Ordered and provided an option to change the order. Fixes spring-projectsgh-11607
I spent some time analysing the the issue. The reason is when So the possible work around for if anybody facing right away is...
Remove @snicoll I have simulated the effect in integration test; pull request coming soon. |
I wouldn't call this a workaround as it requires you to drop the handler mapping that's perfectly valid. The actual workaround that's viable would involve, as you initially suggested, extending the That being said, I'm not sure Boot should make implementing IMO Boot should consider having a well defined (and tested) order of web filters it provides/configures which would make it easier both for Boot itself and users to add new filters to the mix as the results would be predictable. |
@vpavic Absolutely sorry on my miscommunication in wording. I always meant |
I'm not in favor of using I don't think we can really consistently test filters and their ordering as we'd need to include all auto-configurations or risk missing something if we add a new filter somewhere. Also, some auto-configurations are excluding each other, so this is more complex than that. Same thing for the startup check: I'm worried this would be either too late, or it could trigger early initialization of filters and lead to other issues. The only idea I've got so far is reviewing the priorities and documenting them, especially for: |
If i understand it right, the better option is to ensure |
@bclozel if this is a reasonable default, Let's use the Let me know your thoughts. |
@bclozel let me know if you need the test in the pull request, i can a separate on containing only the test. |
Actuator's
WebMvcMetricsFilter
has a hard-coded order ofOrdered.HIGHEST_PRECEDENCE
, which in practice puts it ahead ofCharacterEncodingFilter
. SinceWebMvcMetricsFilter
performs the mapping introspection, under some circumstances it will touch the POST data hence breaking theCharacterEncodingFilter
.I've managed to put together a sample app that exhibits this behavior with a specific set of request mapping paths. After starting the app, issue the following HTTP POST request (samples use HTTPie):
When
spring-boot-starter-actuator
is removed from the dependencies, which getsWebMvcMetricsFilter
out of the picture, request is processed as expected:The text was updated successfully, but these errors were encountered: