Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-15369

Regression: CssLinkResourceTransformer is now incompatible with relative links

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 5.0 M3, 5.0 M4, 5.0 M5
    • Fix Version/s: 5.0 RC1
    • Component/s: Web
    • Labels:
    • Last commented by a User:
      false

      Description

      Issue caused by SPR-14597 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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bclozel Brian Clozel
                Reporter:
                milosz Miłosz S
                Last updater:
                Stéphane Nicoll
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  1 year, 16 weeks, 6 days ago