Skip to content

fix: wrong existence check in getStaticResource (#24283) (CP: 25.1)#24284

Merged
vaadin-bot merged 1 commit into
25.1from
cherry-pick-24283-to-25.1-1778144366589
May 7, 2026
Merged

fix: wrong existence check in getStaticResource (#24283) (CP: 25.1)#24284
vaadin-bot merged 1 commit into
25.1from
cherry-pick-24283-to-25.1-1778144366589

Conversation

@vaadin-bot
Copy link
Copy Markdown
Collaborator

This PR cherry-picks changes from the original PR #24283 to branch 25.1.

Original PR description

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.

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.
@github-actions github-actions Bot added the +0.0.1 label May 7, 2026
@vaadin-bot
Copy link
Copy Markdown
Collaborator Author

This PR is eligible for auto-merging policy, so it has been approved automatically. If there are pending conditions, auto merge (with 'squash' method) has been enabled for this PR [Message is sent from bot]

@vaadin-bot vaadin-bot enabled auto-merge (squash) May 7, 2026 09:07
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2026

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Test Results

 1 388 files  ±0   1 388 suites  ±0   1h 18m 44s ⏱️ + 2m 44s
10 022 tests +1   9 952 ✅ +1  70 💤 ±0  0 ❌ ±0 
10 495 runs  +1  10 416 ✅ +1  79 💤 ±0  0 ❌ ±0 

Results for commit 7d0f0f7. ± Comparison against base commit 6a6e90a.

@vaadin-bot vaadin-bot merged commit 0648006 into 25.1 May 7, 2026
29 checks passed
@vaadin-bot vaadin-bot deleted the cherry-pick-24283-to-25.1-1778144366589 branch May 7, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants