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
Call to addResourceLocations should not always be mandatory [SPR-12133] #16749
Comments
Rossen Stoyanchev commented Do you mean a call to addResourceLocations? As in your (related) comment here? |
Guillaume DROUET commented Yes exactly. Here is an example: https://github.com/wuic/wuic-samples/blob/wuic-0.5.x-snapshot/spring-sample/src/main/java/com/github/wuic/spring/WuicWebConfig.java#L194-L198 WuicPathResourceResolver does not care if there is resources or not. It uses the underlying framework mechanism so I should be able to configure the registry without calling addResourceLocations(). This is a requirement which should be indicated by the resolver itself. What do you think? |
Rossen Stoyanchev commented Modified title (was: "Call to addResourceResolver is not always mandatory") |
Rossen Stoyanchev commented I'll have a look. In the very least we can move the assertion or change it to a warning in PathResourceResolver. The trade-off there is that this check is at runtime vs startup. However I see your point that with the addition of a resource resolver chain in 4.1, the assumption that locations are required no longer holds. So that needs to be fixed. |
Rossen Stoyanchev commented I've removed the assertion for a non-empty list of resource locations and improved the text for a pre-existing warning in ResourceHttpRequestHandler (in afterPropertiesSet). Having looked at WuicPathResourceResolver, I am wondering does it still need to extend PathResourceResolver? It seems that with the current state of affairs it wouldn't care even if a PathResourceResolver was added after it. Aside from that the integration looks pretty straight forward. Can't wait to play with the sample! |
Guillaume DROUET commented Ok perfect. Even if you check at runtime it's not important: the server cache will skip this instruction after the first resolution. And if the user really wants to do it when server starts, he can execute resolution of key resources programmatically in order to directly put the result in cache. This is a strategy that WUIC offers but in spring integration the user have to do it by hand. Regarding the inheritance of PathResourceResolver, yes it's not mandatory now. The issue was that custom resolver was executed before the VersionStrategy. However, I think I should keep things like that in order to no create a useless instance of PathResourceResolver that will never get executed. |
Guillaume DROUET commented The issue is not resolved as indicated in this comment: 4df05d1#commitcomment-7599874 |
Brian Clozel commented See commit 2ef20f63. |
Guillaume DROUET opened SPR-12133 and commented
Since the user can specify its own PathResourceResolver (#16740), its underlying implementation may not always require resource locations to be configured. In that case, an unecessary call to addResourceLocations must be done.
Affects: 4.1 RC2
Referenced from: commits 2ef20f6, 4df05d1
The text was updated successfully, but these errors were encountered: