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
-
Activity
| Field | Original Value | New Value |
|---|---|---|
| Description |
Due to 43bd20f28fa185430f7bf06f529db0221f9e79c3, 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). |
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). |
| Link |
This issue relates to |
| Component/s | Intro [ 14308 ] |
| Attachment | 0001-Fix-Tempfile-unlink-actually-delete-the-file-if-it-i.patch [ 60115 ] |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Assignee | Thomas E Enebo [ enebo ] | Charles Oliver Nutter [ headius ] |
| Fix Version/s | JRuby 1.7.0.pre2 [ 18527 ] | |
| Resolution | Fixed [ 1 ] |
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