TempFile#unlink - do not work if #close is not called right before, even if nothing has been done over the file. #678
That won't blow nor delete the file.
Right now it just logs a warning asking to close the file before unlink.
That make sense if the file is actually opened but
Note that the problem is not present on other Ruby implementations.
Btw, the following will work great.
I'm not sure what we can do here.
The original fix (changing to a no-op for JRUBY-6477) was done because we have no way to unlink the file without deleting it and making the stream useless, as is sometimes done to help secure a temporary file (since it will have no dir entry but still remain open and usable). We modified that fix in JRUBY-6688 to actually delete the file if it has already been closed and warn otherwise because it was obviously confusing to have unlink do nothing. My hope was that the warning would be sufficient to tell folks they need to close the file first, and it seems to have brought you to the right point with your code.
If we go all the way back to actually deleting the file, then JRUBY-6477 will be undone. I don't think we can do that.
It might be possible for us to do an actual unlink by using a native downcall via FFI, but I'm reluctant to do that because there will be no equivalent for environments where we can't use native code (or on Windows, where I don't think you can unlink and continue to access a file).
Sorry, but I think this is a wontfix. Just close the file first and you'll be ok.