fix: Normalize bare stylesheet paths to prevent MalformedURLException warnings#24029
fix: Normalize bare stylesheet paths to prevent MalformedURLException warnings#24029
Conversation
…ings Bare paths like "lumo/lumo.css" from @Stylesheet annotations cause a MalformedURLException warning because ServletContext.getResource() requires a leading '/'. Normalize the path in ResourceContentHash before calling getStaticResource(), and document the '/' requirement in VaadinService.getStaticResource() javadoc. Fixes #24028
Test Results 1 386 files ±0 1 386 suites ±0 1h 25m 30s ⏱️ + 1m 2s Results for commit f20da03. ± Comparison against base commit 482b350. This pull request removes 1 and adds 1 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
|
Tested with the Flow CDI starter project, and the exception is not shown anymore. |
| if (resolved.startsWith("./")) { | ||
| resolved = resolved.substring(1); |
There was a problem hiding this comment.
Can this assumption cause any problem if VaadinServlet has a custom mapping?
Indeed, in that case the @Stylesheet annotation should use context:// prefix, but I wonder if assuming ./ is relative to the webapp context path could cause problems.
|



Bare paths like "lumo/lumo.css" from @Stylesheet annotations cause a MalformedURLException warning because ServletContext.getResource() requires a leading '/'. Normalize the path in ResourceContentHash before calling getStaticResource(), and document the '/' requirement in VaadinService.getStaticResource() javadoc.
Fixes #24028