Details
-
Type:
Improvement
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.7.0.pre1
-
Fix Version/s: JRuby 1.7.0.pre2
-
Component/s: Intro, Standard Library
-
Labels:None
-
Number of attachments :
Description
Due to https://github.com/jruby/jruby/commit/43bd20f28fa1854, Tempfile#
{unlink,delete}now do nothing in JRuby.
The comment was very helpful in my search, thanks Charles!
I think the situation could be improved by warning when someone is using unlink or delete.
This behavior being not compatible with MRI, and calling unlink/delete after close(false) actually not deleting the file is quite surprising.
Maybe unlink/delete could actually delete the file if it "isClosed()" before (with #close(false)) ?
This is not a major problem since the proper way to unlink the tempfile is using #close(true). But I expect `tmp.close; tmp.delete` to be similar to tmp.close(true).
Issue Links
- relates to
-
JRUBY-6477
Tempfile#stat raises java.lang.NullPointerException when unlinked
-
This example of `tmp.close; tmp.delete` is actually the first "Good practice" in the documentation of Tempfile:
# Therefore, one should always call #unlink or close in an ensure block, like # this: # # file = Tempfile.new('foo') # begin # ...do something with file... # ensure # file.close # file.unlink # deletes the temp file # end