This fixes a possible race condition where multiple processes download the same package into the same temp dir.
The issue here is that we are using the same filename when creating these temp files. Because of this, two concurrent processes can possibly run into FileAlreadyExistsException when attempting to create the temporary file.
This fixes the problem by using the Files#createTempFile API to ensure that these filenames are unique.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/apple/pkl/pull/584
**Author:** [@bioball](https://github.com/bioball)
**Created:** 7/17/2024
**Status:** ✅ Merged
**Merged:** 7/18/2024
**Merged by:** [@bioball](https://github.com/bioball)
**Base:** `main` ← **Head:** `fix-package-download-race-cond`
---
### 📝 Commits (2)
- [`dcdea3c`](https://github.com/apple/pkl/commit/dcdea3c61710169083baf6afaf245917aa809475) Fix race condition when concurrently downloading packages
- [`e3d240a`](https://github.com/apple/pkl/commit/e3d240a00a59cbdd1321ca4adb3e6b50c4d9cb70) Address PR comments
### 📊 Changes
**2 files changed** (+16 additions, -10 deletions)
<details>
<summary>View changed files</summary>
📝 `pkl-core/src/main/java/org/pkl/core/packages/PackageResolvers.java` (+10 -5)
📝 `pkl-core/src/test/kotlin/org/pkl/core/packages/PackageResolversTest.kt` (+6 -5)
</details>
### 📄 Description
This fixes a possible race condition where multiple processes download the same package into the same temp dir.
The issue here is that we are using the _same_ filename when creating these temp files. Because of this, two concurrent processes can possibly run into `FileAlreadyExistsException` when attempting to create the temporary file.
This fixes the problem by using the `Files#createTempFile` API to ensure that these filenames are unique.
Closes https://github.com/apple/pkl/issues/583
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/584
Author: @bioball
Created: 7/17/2024
Status: ✅ Merged
Merged: 7/18/2024
Merged by: @bioball
Base:
main← Head:fix-package-download-race-cond📝 Commits (2)
dcdea3cFix race condition when concurrently downloading packagese3d240aAddress PR comments📊 Changes
2 files changed (+16 additions, -10 deletions)
View changed files
📝
pkl-core/src/main/java/org/pkl/core/packages/PackageResolvers.java(+10 -5)📝
pkl-core/src/test/kotlin/org/pkl/core/packages/PackageResolversTest.kt(+6 -5)📄 Description
This fixes a possible race condition where multiple processes download the same package into the same temp dir.
The issue here is that we are using the same filename when creating these temp files. Because of this, two concurrent processes can possibly run into
FileAlreadyExistsExceptionwhen attempting to create the temporary file.This fixes the problem by using the
Files#createTempFileAPI to ensure that these filenames are unique.Closes https://github.com/apple/pkl/issues/583
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.