You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 Java HotSpot(TM) 64-Bit Server VM 25.40-b25 on 1.8.0_40-b26 +jit [mswin32-x86_64]
Behavior
In version 9.1.5.0 of Jruby when i use the a+ mode for opening and writing to a file the pointer is at the begining of the file.
The expected behaviour is to position at the end of the file for appending.
The script below works in MRI ruby 2.3.1 but overwrites at the top of the file for Jruby 9.1.5.0 and 9.1.6.0
@qzio yeah it works fine on MacOs as well. Windows does not have all the native methods we would like implemented yet so in places we go down a totally different codepath. I also cannot test whether this works with native support disabled on windows: #4349
@limmet can you tell me if you just happened to be playing with a+ and noticed this or you had a real use case which needs a+? I have been trying to figure out what people use a+ for and would love a real world use case for it. I tried searching online and I got either: a) how does a+ work b) your impl does not support a+ properly c) I am using a+ and it does this weird thing.
So quick note on this one. We did not support a+ when native was disabled OR on windows where we still use pure-Java code for this. The behavior is new to me and I used to do C a gazillion years ago. In a+ mode, you can seek and read all you want but if you write then because O_APPEND is set it will write to the end of the file. Even if you seeked away from the end at some point.
Environment
jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 Java HotSpot(TM) 64-Bit Server VM 25.40-b25 on 1.8.0_40-b26 +jit [mswin32-x86_64]
Behavior
In version 9.1.5.0 of Jruby when i use the a+ mode for opening and writing to a file the pointer is at the begining of the file.
The expected behaviour is to position at the end of the file for appending.
The script below works in MRI ruby 2.3.1 but overwrites at the top of the file for Jruby 9.1.5.0 and 9.1.6.0
date_now = Time.now
path_to_logfile = 'C:/temp/jruby_file_log'
Dir.mkdir path_to_logfile unless File.directory? path_to_logfile
path_to_logfile += "/test_#{date_now.strftime('%Y_%m_%d')}.txt"
File.open(path_to_logfile, 'a+') { |f| f.write("First: #{date_now}\n") }
File.open(path_to_logfile, 'a+') { |f| f.write("Second:#{date_now}\n") }
The text was updated successfully, but these errors were encountered: