Skip to content
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

Regression: CssLinkResourceTransformer is now incompatible with relative links [SPR-15369] #19933

Closed
spring-issuemaster opened this Issue Mar 21, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

spring-issuemaster commented Mar 21, 2017

Miłosz S opened SPR-15369 and commented

Issue caused by #19166 and commit 679b661

Stacktrace:

java.lang.NullPointerException: null
	at org.springframework.web.servlet.resource.ResourceTransformerSupport.toAbsolutePath(ResourceTransformerSupport.java:99) ~[spring-webmvc-5.0.0.BUILD-20170321.085409-1.jar:5.0.0.BUILD-SNAPSHOT]
	at org.springframework.web.servlet.resource.CssLinkResourceTransformer.transform(CssLinkResourceTransformer.java:106) ~[spring-webmvc-5.0.0.BUILD-20170321.085409-1.jar:5.0.0.BUILD-SNAPSHOT]
	at org.springframework.web.servlet.resource.DefaultResourceTransformerChain.transform(DefaultResourceTransformerChain.java:67) ~[spring-webmvc-5.0.0.BUILD-20170321.085409-1.jar:5.0.0.BUILD-SNAPSHOT]
	at org.springframework.web.servlet.resource.ResourceHttpRequestHandler.getResource(ResourceHttpRequestHandler.java:428) ~[spring-webmvc-5.0.0.BUILD-20170321.085409-1.jar:5.0.0.BUILD-SNAPSHOT]
	at org.springframework.web.servlet.resource.ResourceHttpRequestHandler.handleRequest(ResourceHttpRequestHandler.java:323) ~[spring-webmvc-5.0.0.BUILD-20170321.085409-1.jar:5.0.0.BUILD-SNAPSHOT]
	at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51) ~[spring-webmvc-5.0.0.BUILD-20170321.085409-1.jar:5.0.0.BUILD-SNAPSHOT]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) ~[spring-webmvc-5.0.0.BUILD-20170321.085409-1.jar:5.0.0.BUILD-SNAPSHOT]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-5.0.0.BUILD-20170321.085409-1.jar:5.0.0.BUILD-SNAPSHOT]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:964) ~[spring-webmvc-5.0.0.BUILD-20170321.085409-1.jar:5.0.0.BUILD-SNAPSHOT]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:856) ~[spring-webmvc-5.0.0.BUILD-20170321.085409-1.jar:5.0.0.BUILD-SNAPSHOT]

Steps and reason:

  1. CssLinkResourceTransformer parses relative link in CSS file
  2. Tries to resolve it by calling ResourceTransformerSupport#toAbsolutePath(...)
  3. toAbsolutePath(...) calls this.getResourceUrlProvider()
  4. BUT from documentation of setResourceUrlProvider() we know that: "This is required only for links expressed as full paths, i.e. including context and servlet path, and not for relative links. By default this property is not set."

So toAbsolutePath is breaking a contract by requiring resourceUrlProvider even for relative paths. See method resolveUrlPath() for ideas what could be a possible fix.


Affects: 5.0 M3, 5.0 M4, 5.0 M5

Issue Links:

  • #19166 CssLinkResourceTransformer is incompatible with ContentVersionStrategy when using Caching

Referenced from: commits 2baceac

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Mar 24, 2017

Brian Clozel commented

Thanks!
I've also aligned the documentation on webmvc and webflux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.