codeconsole commented on PR #16760:
URL: https://github.com/apache/grails-core/pull/16760#issuecomment-6450590267

   > with the startup progress, doesn't this highest precedence cause that to 
have the encoding added too? Should it really be the absolutely highest?
   
   No, startup progress runs ahead of the encoding filter. Its filter is a 
`FilterRegistrationBean` at `Ordered.HIGHEST_PRECEDENCE`, and Spring Boot's 
encoding filter is a plain `Filter` bean at the same order; Boot puts 
registration beans first when the orders are equal. I started the 
startup-progress example with `grails.startup.progress.enabled=true` and listed 
the filters in the order Boot registers them:
   
   ```
   grailsStartupProgressFilter  HIGHEST_PRECEDENCE      StartupProgressFilter
   grailsCorsFilter             HIGHEST_PRECEDENCE      GrailsCorsFilter
   characterEncodingFilter      HIGHEST_PRECEDENCE      
OrderedCharacterEncodingFilter
   webMvcObservationFilter      HIGHEST_PRECEDENCE + 1  
ServerHttpObservationFilter
   formContentFilter            -9900                   OrderedFormContentFilter
   grailsSecurityHeadersFilter  -200                    
GrailsSecurityHeadersFilter
   grailsWebRequestFilter       -150                    GrailsWebRequestFilter
   ```
   
   While the application starts, the startup progress filter answers without 
continuing the chain, so the encoding filter never sees those requests. It 
reads no parameters or body, and it sends its bytes with an explicit 
`;charset=utf-8`, so the encoding filter would not change what it serves even 
if it ran first. `CharacterEncodingSpec` pins the tie-break with a 
`FilterRegistrationBean` at `HIGHEST_PRECEDENCE`. Grails' CORS filter is a 
plain bean at that order too, so it ties with the encoding filter and lands 
ahead of it here by bean definition order; it reads no parameters. #16768 is 
the same on 8.1.x, where Grails' encoding filter is also a plain `Filter` bean.
   
   As for whether it should be the very highest: on 9.0 this is Spring Boot's 
filter at the order Spring Boot gives it in every application. This PR only 
stops Grails from turning it off. It is first because the request encoding has 
to be set before anything reads a parameter or the body. A filter that has to 
run ahead of it can, as startup progress does, if it reads no parameters.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to