History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JRUBY-829
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Charles Oliver Nutter
Reporter: Charles Oliver Nutter
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
JRuby

Open File objects are not flushing on exit

Created: 17/Apr/07 03:08 PM   Updated: 06/May/07 09:49 PM
Component/s: Core Classes/Modules
Affects Version/s: JRuby 0.9.9
Fix Version/s: JRuby 1.0.0RC1

Time Tracking:
Not Specified

File Attachments: 1. Text File ensure_flush.patch (5 kb)


Testcase included: yes


 Description  « Hide
Run the t.rb script from JRUBY-65. It attempts to write out to a file using code of the form:
File.new("somefile", "w").write(somestring)

at the end of the script, but the contents are never flushed out to the file. This is likely due to our new IOHandlerSeekable implementation that buffers RandomAccessFile. A small bug, only affecting the end of a script/app's run, but something we must fix before 1.0.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Damian Steer - 24/Apr/07 02:19 PM
Looking at MRI it seems to be flushing in the finalizer:
static void
fptr_finalize(rb_io_t *fptr, int noraise)
{
    if (fptr->wbuf_len) {
        io_fflush(fptr);
    }
   ......
}

We can't guarantee that our version will run, so it seems like we may need a clean up when the runtime exits. I'll have a crack at it.


Damian Steer - 24/Apr/07 05:54 PM
This seems to do the trick for the supplied test case. Costs an interface, but c'est la vie.

Charles Oliver Nutter - 05/May/07 07:10 PM
Seems like a clean enough fix; getting it into RC will let it bake for 1.0.

Charles Oliver Nutter - 06/May/07 09:49 PM
Closing for 1.0RC1