Skip to content

14.6 breaks if a ZipFileSystemProvider has been initialized before Vaadin serves a static file from the jar. #11378

Closed

Description

@jflamy

Description of the bug / feature

If a program creates a Zip File System before Vaadin does, then when Vaadin attempts to serve a file from the jar (for example, an image under META-INF/resources/frontend) it fails.

Minimal reproducible example

Add a "templates" folder in the classes directory (src/main/resources/templates in Maven convention)
Open a zip file system in the Main class of a fat jar (or equivalent Spring Boot construct), before Vaadin gets to see a request.
Package as a fat jar and run. URI must be a "jar" for the code to fail.

URL resources = ResourceWalker.class.getResource("/templates");
URI resourcesURI = resources.toURI();
FileSystems.newFileSystem(resourcesURI, Collections.<String, Object>emptyMap());

Expected behavior

Vaadin should ignore the fact that there is already a Zip File System Provider configured. Try Paths.get() and if fails on FileSystemNotFoundException open the file system.

Actual behavior

java.nio.file.FileSystemAlreadyExistsException
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:102)
at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:337)
at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:286)
at com.vaadin.flow.server.StaticFileServer.getFileSystem(StaticFileServer.java:212)
at com.vaadin.flow.server.StaticFileServer.resourceIsDirectory(StaticFileServer.java:145)
at com.vaadin.flow.server.StaticFileServer.isStaticResourceRequest(StaticFileServer.java:113)
at com.vaadin.flow.server.VaadinServlet.serveStaticOrWebJarRequest(VaadinServlet.java:290)
at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:239)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

Versions:

- Vaadin / Flow version:  observed on 14.6.2 and up
- Java version:  11
- OS version: Ubuntu-20.04
- Browser version (if applicable): n/a
- Application Server (if applicable): Embedded Jetty 9.2.4
- IDE (if applicable): n/a

Activity

  1. TatuLund commented on Jul 7, 2021

    @TatuLund
    Contributor

    Your issue looks very similar to this one #11144

  2. jflamy commented on Jul 7, 2021

    @jflamy
    Author

    Yes. Have not looked at the fix. If Vaadin protects itself using concurrency mechanisms such as a latch, then it's possible that the case where it's not Vaadin stepping over itself would not be covered. The bug is still present in 14.6,5

  3. jflamy commented on Jul 7, 2021

    @jflamy
    Author

    Issue #11144 is claimed to be fixed in 14.6.3. This related issue still occurs in 14.6.5, so the fix to 11444 is perhaps incomplete.

  4. self-assigned this
    on Jul 19, 2021
  5. added 2 commits that reference this issue on Jul 19, 2021
    67b83fa
    3112916
  6. caalador commented on Jul 19, 2021

    @caalador
    Contributor

    11444 is internal concurrent handlers where as this issue is when an external has already opened a FileSystem for the same resource.

  7. added a commit that references this issue on Jul 19, 2021
    dd6ff5d
  8. added 3 commits that reference this issue on Jul 19, 2021
    d5ca598
    b56fd7e
    3b7a966
  9. 1 remaining item

  10. added 4 commits that reference this issue on Jul 19, 2021
    0ec1010
    32301ac
    5cc8f53
    4d817ac
  11. vaadin-bot commented on Jul 26, 2021

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with platform 14.6.7. For prerelease versions, it will be included in its final version.

  12. vaadin-bot commented on Jul 26, 2021

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with platform 20.0.5. For prerelease versions, it will be included in its final version.

  13. vaadin-bot commented on Aug 6, 2021

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with platform 21.0.0.beta1 and is also targeting the upcoming stable 21.0.0 version.

  14. vaadin-bot commented on Aug 9, 2021

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with platform 14.7.0.alpha3 and is also targeting the upcoming stable 14.7.0 version.

  15. added a commit that references this issue on Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions