Add missing CORS headers defined in SockJS CORS config
Prior to this commit and following changes done in d27b5d0, the CORS
response headers would not be added for SockJS-related requests, even
though a CORS configuration had been applied to SockJS/WebSocket.
This was due to a missing case in our implementation: calling
`AbstractHandlerMapping#getHandlerInternal` can return a Handler
directly, but also a `HandlerExecutionChain` in some cases, as explained
in the Javadoc.
This commit ensures that, when checking for existing CORS configuration,
the `AbstractHandlerMapping` class also considers the
`HandlerExecutionChain` case and unwraps it to get the CORS
configuration from the actual Handler.
Fixes gh-23843
This commit is contained in:
@@ -485,6 +485,9 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
|
||||
* @since 5.2
|
||||
*/
|
||||
protected boolean hasCorsConfigurationSource(Object handler) {
|
||||
if (handler instanceof HandlerExecutionChain) {
|
||||
handler = ((HandlerExecutionChain) handler).getHandler();
|
||||
}
|
||||
return (handler instanceof CorsConfigurationSource || this.corsConfigurationSource != null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user