Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8307536

FileAlreadyExistsException from NativeLibLoader when running concurrent applications with empty cache

    XMLWordPrintable

Details

    • b05

    Backports

      Description

        In a CI environment, or while unit testing, it is common to run several tests in parallel, while cleaning initially the cache:

        rm -rf ~/.openjfx/cache/
        mvn clean test

        (or gradle or any other build tool for that matter).

        In this scenario, it is possible that one of the test fails, and this exception (or similar) can be seen:

        Error: Loading library prism_es2 from resource failed: java.nio.file.FileAlreadyExistsException:~/.openjfx/cache/21-ea+5/aarch64/libprism_es2.dylib
        java.nio.file.FileAlreadyExistsException: ~/.openjfx/cache/21-ea+5/aarch64/libprism_es2.dylib
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:94)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:218)
        at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:484)
        at java.base/java.nio.file.Files.newOutputStream(Files.java:228)
        at java.base/java.nio.file.Files.copy(Files.java:3160)
        at com.sun.glass.utils.NativeLibLoader.cacheLibrary(NativeLibLoader.java:303)
        at com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:215)
        at com.sun.glass.utils.NativeLibLoader.loadLibraryFromResource(NativeLibLoader.java:197)
        at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:138)
        at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:54)
        at com.sun.prism.es2.ES2Pipeline.lambda$static$0(ES2Pipeline.java:63)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
        at com.sun.prism.es2.ES2Pipeline.<clinit>(ES2Pipeline.java:52)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:375)
        at com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:218)
        at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:92)
        at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
        at java.base/java.lang.Thread.run(Thread.java:833)

        While NativeLibLoader::loadLibrary is synchronized, this doesn't work while running from different JVMs.

        Since each test uses a different process, the above exception can happen when a library file is being written to the cache as part of one process, while the other process doesn't find it yet and tries to create it as well.

        Possible workaround: This error could be prevented if the tests run in serial instead, or if there was a initial step to set the cache before the tests could run.

        Attachments

          Issue Links

            Activity

              People

                jpereda Jose Pereda
                jpereda Jose Pereda
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: