Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix race condition by memoizing
Tempfile
objects
Previously, the `certificate` and `private_key` methods created `Tempfile` objects without maintaining references after the methods exited. This allowed the Ruby garbage collector to collect and delete these temporary files at any time. As a result, there was a race condition where the `keytool` binary could fail with a `java.io.FileNotFoundException` if the temporary files were deleted before `keytool` accessed them. This commit resolves the issue by memoizing the `Tempfile` objects using instance variables (`@temp_certificate_file` and `@temp_private_key_file`). By caching these objects, we prevent them from being garbage collected prematurely, ensuring that the temporary files remain available for the duration of the provider instance. Fixes #425
- Loading branch information