Skip to content

File.size (org.jruby.RubyFile.size() ) impacts underlying file handle #1272

@jayjlawrence

Description

@jayjlawrence

Using Jruby 1.7.8 deployed in a Tomcat7 container (warbled war) - I have created a demonstration project

I have not recreated the issue but have isolated and observed it in my application code.

Using the "spreadsheet" gem in Windows relies on the Ruby-OLE gem. This gem was returning a IOError exception on a @io.rewind statement. @io is a File object.

Bisecting the issue I have narrowed it down to immediately prior to the @io.rewind is a @io.size > 0 test. If this is changed to @io.stat.size > 0 then the code proceeds. This suggests that the RubyFile size method irritates an (probably Windows) issue that damages the underlying file handle.

How do you feel about using the same approach as with "ctime" or "atime"? i.e. context.runtime.newFileStat vs runtime.getPosix().fstat ... just a thought.

I have created a project that demonstrates is issue at https://github.com/jayjlawrence/jruby-File.size

System stats:
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

Windows 2008 R2 64 bit in a VMware VM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions