-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
Clarify how to avoid favoring path extensions as well as deprecation warnings #24642
Comments
No, you're not. This is very long standing behavior and changing the default can cause significant disruption but maintenance releases are intended to be trouble free so you can take advantage of fixes including security issues, if any. The purpose of the deprecation and #24179 is:
Note that even in 5.3 we will turn off automatic matching to all extensions, but continue to match explicitly registered extensions by default and so |
I'm not quite sure I understand, please correct me if I'm wrong. I used to have an url like Now in order to do that I need to call a deprecated method. In the future, I will not need to call any method, since this is going to be the default behaibour |
That's a very good point but switching the default would likewise defeat the goal of a gradual migration through advance warning and deprecation. It means we need to explain how to be configured which is: // 1)
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.useRegisteredExtensionsOnly(true);
configurer.replaceMediaTypes(Collections.emptyMap());
}
// 2)
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
// the below will become the default values in 5.3
configurer.useSuffixPatternMatch(false);
configurer.useRegisteredExtensionsOnly(true);
}
|
I originally asked this same question on #24179, but I see you started to answer it here. Unfortunately with Spring 5.2.5 I cannot get 2) of your recommendation to work: there is no useSuffixPatternMatch or useRegisteredExtensionsOnly method in org.springframework.web.servlet.config.annotation.PathMatchConfigurer; I do see the old deprecated "set" versions of those methods, but I thought the suggestion here was how to get around the warnings before 5.3 is released. |
Indeed my bad. Technically the proper thing to do would be to deprecate them in 5.3 when the defaults values will change and those methods can be avoided altogether. That said I'd really like to keep the deprecations in 5.2 to maximize advance warning and provide extra time to adapt. Therefore in 5.2 applications will have to use these deprecated methods but as long as they are used to turn off suffix pattern matching, it's okay to suppress the deprecation warnings. Then in 5.3 we will change the default values (but not yet remove the config options), and at that applications can remove their use. This is what I'll have to update the docs with. |
Great, thanks. Here is what I have then.
|
Also, I'm not sure if you saw my comment in #24179, but I had also suggested, to bridge the gap between 5.2.4+ and 5.3, adding a disableUseSuffixPatternMatch() method to be deprecated in 5.3 that disables the functionality (same as above). This would allow a non-deprecated method to set the 5.3 functionality while still allowing the to-be-removed methods to be deprecated in 5.2.4+. |
I thought about that but I don't see how it helps since that method will also need to be removed together with the rest and therefore would also need to be deprecated. |
Just for completeness, this solution worked for my production code but my unit testing with MockMvc it did not. What worked for me (not sure if there is another way) is to use |
Affects: 5.2.4.RELEASE
According to 24179 favorPathExtension is deprecated, and we should all use the Accept header, which is perfect for me, since I always use favorPathExtension = false
The setter in ContentNegotiationManagerFactoryBean is Deprecated, but the field value is true (line 108) , so as far as I understand, the use of path seems in fact encouraged, since is the default value and the only way to set as false is Deprecated
Am I getting something wrong?
The text was updated successfully, but these errors were encountered: