-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Avoid error at shutdown if tmpdir is not writeable but was not used in the first place #13039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| private val TempDirectoryPrefix = "playtemp" | ||
| private val TempDirectoryPrefix = "playtemp" | ||
| private var TempFolderCreated: Boolean = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @gaeljw! Thanks a lot to your contribution 👍
In common I agree with this approach, but personally, I would prefer to change type of private playTempFolder and use Option/Either for them instead of add a new boolean field. It'll be a more idiomatic way instead of manually sync a state of two Path and Boolean vars 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ihostage I agree it's not the best pattern but I wanted to keep the laziness of playTempFolder.
Are you suggesting to have a mutable Option[Path] and replace the lazy val creation of the folder by something like playTempFolder.getOrElse(create...) in the create method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I thought like this
private lazy val playTempFolder: Either[Throwable, Path] =
try {
...
Right(tmpFolder)
} catch {
case t: Throwable => Left(t)
}But now, I realize that this approach still creates and deletes a temporary folder unnecessarily, just potentially hide an error message in the log via the stop hook implementation. I don't like this. 😄
Need to think 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented the alternative you talked about in #13110
What do you guys think / prefer?
I don't really care.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight preference for my initial proposal that I find more explicit but I'm fine with yours as well.
Let's get one of the two merged :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alternative suggestion does not work anyway, because it can cause race conditions, see #13110 (comment)
Therefore lets just merge this PR finally.
…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
|
@Mergifyio backport 3.0.x 2.9.x |
|
This pull request has been removed from the queue for the following reason: The pull request can't be updated You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. If you want to requeue this pull request, you need to post a comment with the text: |
✅ Backports have been createdDetails
|
|
We can include this in our next patch release. |
Pull Request Checklist
Helpful things
Fixes
Fixes #13013
Purpose
Do not try to delete the temporary folder during shutdown if it was never created in the 1st place. Because when trying to delete, it actually tries to create the folder if it was not already created. This is useless and can cause errors with read-only filesystems.
Background Context
I used a simple mutable
varas I believe this is enough in this context: thevaris private, in a singleton, only set during alazy valinitialization.However, if you believe we should use an
AtomicBoolean, just say it :)Note that I didn't add test, not sure if this is worth it and I'm not sure how to approach writing such a test.
References
N/A