Spring Boot version: 2.3.5.RELEASE
The server.tomcat.use-relative-redirects
property is incorrectly marked as deprecated in the spring-configuration-metadata.json
of the spring-boot-autoconfiguration
module
The problem is that the server.tomcat.use-relative-redirects
is not deprecated, but only the Boolean
typed getter and setter methods of the org.springframework.boot.autoconfigure.web.ServerProperties.Tomcat#useRelativeRedirects
are deprecated (see the daed512076796bb1de51f0d04ff5ca2ebdd3c322 commit and the #20796 issue for the related changes). The addition of the @Deprecated
to the Boolean getUseRelativeRedirects
caused the deprecated
to be set on true for the server.tomcat.use-relative-redirects
entry in the spring-configuration-metadata.json
of the spring-boot-autoconfiguration
module.
The incorrect deprecation of this property now causes the properties migration listener to warn about the use of this property:
The use of configuration keys that are no longer supported was found in the environment:
Property source 'applicationConfig':
Key: server.tomcat.use-relative-redirects
Reason: none
Please refer to the release notes or reference guide for potential alternatives.
The Intellij application properties editor now also warns about setting this property.
Comment From: snicoll
Good catch @mzeijen, we wanted to re-introduce the Boolean
version in a deprecated fashion but unfortunately that triggered the annotation processor the way you indicated.
See #20796
Comment From: snicoll
Unfortunately, we won't be able to "undo" the deprecation with manual metadata as things stand. Manual metadata is used to override the reason, replacement or level but not the fact the property is deprecated.
Comment From: mzeijen
For now I created a workaround where I set the useRelativeRedirects
directly on the Tomcat Context via a WebServerFactoryCustomizer<TomcatServletWebServerFactory>
.
Luckily you made it possible to have multiple roads to Rome :).
It would be nice to be able to get rid of this workaround at some point, so I would appreciate some kind of fix. But if that can only happen in a next big release of Spring Boot, then so be it.
Comment From: snicoll
I've repurposed this issue to fix a bug in the annotation processor where it may use the wrong accessor for a boolean type in case of multiple candidates, as in this case. The former Boolean
accessor for the properties are deprecated and we should use the one matching the field type, really (boolean
). Doing so will prevent the property to be wrongly identified as deprecated.
Comment From: mzeijen
That is a great solution. Thank you very much.