Commit 30cf92c
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>
1 parent ace9144 commit 30cf92c
2 files changed
Lines changed: 61 additions & 10 deletions
File tree
- flow-server/src
- main/java/com/vaadin/flow/server
- test/java/com/vaadin/flow/server
Lines changed: 10 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | 27 | | |
30 | 28 | | |
31 | 29 | | |
| |||
325 | 323 | | |
326 | 324 | | |
327 | 325 | | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| |||
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| 18 | + | |
14 | 19 | | |
| 20 | + | |
| 21 | + | |
15 | 22 | | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
| 26 | + | |
19 | 27 | | |
| 28 | + | |
20 | 29 | | |
21 | 30 | | |
22 | 31 | | |
| |||
48 | 57 | | |
49 | 58 | | |
50 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
51 | 63 | | |
52 | 64 | | |
53 | 65 | | |
| |||
313 | 325 | | |
314 | 326 | | |
315 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
316 | 367 | | |
317 | 368 | | |
318 | 369 | | |
| |||
0 commit comments