RFR: 8307536: FileAlreadyExistsException from NativeLibLoader when running concurrent applications with empty cache
Jose Pereda
jpereda at openjdk.org
Sun Jul 30 09:08:50 UTC 2023
On Fri, 28 Jul 2023 09:11:07 GMT, Jose Pereda <jpereda at openjdk.org> wrote:
> This PR adds a file lock to the cache directory, allowing access from multiple processes (that is, from more than one JVM) to that directory.
>
> This helps solving the issue where the cache is empty or doesn't exist yet, and two JavaFX applications start at the same time, and both try to copy the same native libraries to the same cache.
>
> No tests have been added to the PR though, since this requires a complex scenario: building the SDK and publishing to local Maven repository, creating two simple JavaFX applications that use those artifacts, using a temporary folder for cache (via `javafx.cachedir`, and launching in parallel both applications.
>
> I've tested successfully such scenario on Linux, Mac and Windows.
This PR tries to solve the issue of two (or more) concurrent attempts to do the same thing when different JavaFX applications are launched at the same time, in case the cache was empty (or gets cleaned for some reason), and I've tested successfully such scenario on Linux, Mac and Windows.
The cache directory doesn't get permanently locked, but only for a short period of time, while a file is being copied to it from resources.
Therefore, I don't think there should be any issue with old running JVMs. Typically all the access to the cache is done during the launch of an application, where native libraries are loaded. And if you remove the cache folder _after_ the application was launched, it will still continue working. If for any reason it needs to access the cache after that, as I said, it won't be locked.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1188#issuecomment-1657085702
More information about the openjfx-dev
mailing list