fix: wrong existence check in getStaticResource (CP: 25.0)#24285
Merged
fix: wrong existence check in getStaticResource (CP: 25.0)#24285
Conversation
On Jetty 12.1.9, requests for static resources packaged inside a JAR (e.g. `vaadinPush.js` from `flow-push`) fail with `FileSystemNotFoundException`. `VaadinServletService.getStaticResource` verifies the URL returned by `ServletContext.getResource` via `Path.of(url.toURI())`, which for a `jar:file:...!/entry` URI requires the JAR's NIO `FileSystem` to already be mounted in the JVM-wide cache. Jetty 12.1.8 incidentally kept those filesystems mounted during resource resolution; 12.1.9 no longer does, so `getFileSystem` throws and the existing `catch (URISyntaxException)` lets the unchecked exception escape, producing HTTP 500. Probe the URL with `URL.openStream()` instead. `JarURLConnection` and `FileURLConnection` use `java.util.jar.JarFile` / `java.io.File` directly and are independent of the NIO `FileSystems` cache, so the check works uniformly for `file:` and `jar:file:` URLs and on every Jetty 12 build. The catch is broadened to `IOException`, covering both missing files (the original Jetty 12 workaround) and missing JAR entries.
|
caalador
approved these changes
May 7, 2026
vaadin-bot
added a commit
that referenced
this pull request
May 7, 2026
…CP: 24.10) (#24286) This PR cherry-picks changes from the original PR #24285 to branch 24.10. --- #### Original PR description > This PR cherry-picks changes from the original PR #24283 to branch 25.0. > > A conflict in `flow-server/src/test/java/com/vaadin/flow/server/VaadinServletServiceTest.java` was resolved manually: the new `getStaticResource_jarUrlOnJetty12_returnsUrlInsteadOfThrowing` test was rewritten in JUnit 4 idioms (`@Rule TemporaryFolder`, `Assert.*`) since 25.0 has not adopted the JUnit 5 migration that landed on `main`. > > --- > > > On Jetty 12.1.9, requests for static resources packaged inside a JAR (e.g. `vaadinPush.js` from `flow-push`) fail with > > `FileSystemNotFoundException`. `VaadinServletService.getStaticResource` verifies the URL returned by `ServletContext.getResource` via `Path.of(url.toURI())`, which for a `jar:file:...!/entry` URI requires the JAR's NIO `FileSystem` to already be mounted in the JVM-wide cache. Jetty 12.1.8 incidentally kept those filesystems mounted during resource resolution; 12.1.9 no longer does, so `getFileSystem` throws and the existing `catch (URISyntaxException)` lets the unchecked exception escape, producing HTTP 500. > > > > Probe the URL with `URL.openStream()` instead. `JarURLConnection` and `FileURLConnection` use `java.util.jar.JarFile` / `java.io.File` directly and are independent of the NIO `FileSystems` cache, so the check works uniformly for `file:` and `jar:file:` URLs and on every Jetty 12 build. The catch is broadened to `IOException`, covering both missing files (the original Jetty 12 workaround) and missing JAR entries. Co-authored-by: Marco Collovati <marco@vaadin.com>
vaadin-bot
added a commit
that referenced
this pull request
May 7, 2026
…CP: 24.9) (#24287) This PR cherry-picks changes from the original PR #24285 to branch 24.9. --- #### Original PR description > This PR cherry-picks changes from the original PR #24283 to branch 25.0. > > A conflict in `flow-server/src/test/java/com/vaadin/flow/server/VaadinServletServiceTest.java` was resolved manually: the new `getStaticResource_jarUrlOnJetty12_returnsUrlInsteadOfThrowing` test was rewritten in JUnit 4 idioms (`@Rule TemporaryFolder`, `Assert.*`) since 25.0 has not adopted the JUnit 5 migration that landed on `main`. > > --- > > > On Jetty 12.1.9, requests for static resources packaged inside a JAR (e.g. `vaadinPush.js` from `flow-push`) fail with > > `FileSystemNotFoundException`. `VaadinServletService.getStaticResource` verifies the URL returned by `ServletContext.getResource` via `Path.of(url.toURI())`, which for a `jar:file:...!/entry` URI requires the JAR's NIO `FileSystem` to already be mounted in the JVM-wide cache. Jetty 12.1.8 incidentally kept those filesystems mounted during resource resolution; 12.1.9 no longer does, so `getFileSystem` throws and the existing `catch (URISyntaxException)` lets the unchecked exception escape, producing HTTP 500. > > > > Probe the URL with `URL.openStream()` instead. `JarURLConnection` and `FileURLConnection` use `java.util.jar.JarFile` / `java.io.File` directly and are independent of the NIO `FileSystems` cache, so the check works uniformly for `file:` and `jar:file:` URLs and on every Jetty 12 build. The catch is broadened to `IOException`, covering both missing files (the original Jetty 12 workaround) and missing JAR entries. Co-authored-by: Marco Collovati <marco@vaadin.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This PR cherry-picks changes from the original PR #24283 to branch 25.0.
A conflict in
flow-server/src/test/java/com/vaadin/flow/server/VaadinServletServiceTest.javawas resolved manually: the newgetStaticResource_jarUrlOnJetty12_returnsUrlInsteadOfThrowingtest was rewritten in JUnit 4 idioms (@Rule TemporaryFolder,Assert.*) since 25.0 has not adopted the JUnit 5 migration that landed onmain.