Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mkurz
Copy link
Member

@mkurz mkurz commented Feb 15, 2025

I don't have a preference, I just tried who thinks look like with the Option approach.

…ry folder (fix playframework#13013)

With a read-only filesystem, an error was raised during shutdown when trying to delete the temporary
folder because delete would first create the folder if it was not yet created.

fix playframework#13013
private lazy val playTempFolder: Path = {
private val TempDirectoryPrefix = "playtemp"
private var _playTempFolder: Option[Path] = None
private def playTempFolder: Path = _playTempFolder.getOrElse {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we have a failing test now:

[error]   x not have a race condition when creating temporary files (794 ms)
[error]    the value is false (TemporaryFileCreatorSpec.scala:90)

The test ends with this line:

// All temporary files should be created at the same directory
results.forall(_.path.getParent.equals(parentDir)) must beTrue

So the problem is the code _playTempFolder.getOrElse { ... } is not atomic. Multiple threads can enter the getOrElse { ... } body, create a new tempfolder and update the _playTempFolder var and the `temporaryFileReaper´ tmp folder.

So this alternative does not work without syncing some code, therefore lets just merge #13039 instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, I thought about it for a sec and said to myself "we don't really care" but that's nice that a test caught it :) Because now that I think about it more, we do care! It could lead to some inconsistencies and not clean things properly at shutdown.

@mkurz mkurz closed this Feb 16, 2025
@mkurz mkurz deleted the gh13013-alternative branch February 16, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants