-
Notifications
You must be signed in to change notification settings - Fork 137
8373825: [lworld] ForwardingFileManager always closes its delegate leading to ClosedFileSystemException in TestOriginatingElements #1810
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
base: lworld
Are you sure you want to change the base?
Conversation
|
👋 Welcome back david-beaumont! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
Webrevs
|
| new JavacTask(tb).fileManager(memoryFM2) | ||
| .sources(bJava, aJava) | ||
| .run(); | ||
| try (var memoryFM1 = new ToolBox.MemoryFileManager(fm, 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.
I could leave this alone, but it seemed nicer to actually acknowledge that the file managers are closeable.
| * @param shouldClose whether the delegate file manager should be closed | ||
| * when this instance is closed | ||
| */ | ||
| public MemoryFileManager(JavaFileManager fileManager) { |
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.
Only called in 2 places, so migrating callers with an extra parameter is easy.
| * Constructs a memory file manager which stores output files in memory, | ||
| * and delegates to a default file manager for input files. | ||
| */ | ||
| public MemoryFileManager() { |
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.
This is the vast majority of users, they don't care about the delegated instance and want it closed.
|
I think the standard way to change behavior for For |
|
Fair enough, that was my other thought, but since it's analogous to various I/O file/stream forwarding APIs which do explicitly call out whether the delegate should be closed, I thought I'd push on that route first. |
|
Actually the more I think about it, the more I'm convinced it's a better API if the forwarding class knows whether to close or not. The reasoning is this:
While it's not a forcing function (the other constructor with original behaviour must still exist), there's more chance users encountering the class for the first time will think about the issue, compared to having to just remember that lifetime ownership is a thing and what the forwarding class does. |
Allow users of ForwardingFileManager to specify if the delegate file manager should also be closed.
This fixes a use-after-close bug in TestOriginatingElements, where the system file manager and wrapping memory file manager have different, nested, lifetimes resulting in an early call to close the system file manager when the wrapper is closed, causing subsequent legitimate use of the system file manager to fail.
This wasn't noticed before now since the system file manager was using the singleton JRT file-system in which "close" does nothing. Now it's using a properly scoped instance of the JRT file-system which can be closed.
This fix could also probable go straight into mainline as a clone since it won't break anything there.
Progress
Error
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/1810/head:pull/1810$ git checkout pull/1810Update a local copy of the PR:
$ git checkout pull/1810$ git pull https://git.openjdk.org/valhalla.git pull/1810/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1810View PR using the GUI difftool:
$ git pr show -t 1810Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1810.diff
Using Webrev
Link to Webrev Comment