Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.1b1
-
Fix Version/s: JRuby 1.1RC1
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:Windows XP SP2, JRuby 1.1b1, Mongrel 1.1.1
Ruby IRB using ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
-
Number of attachments :
Description
During a file rename operation, when the destination file exist, Ruby will overwrite the destination file with the source.
With JRuby, both files are untouched. As a result, the log rotation fails (no rotation occurs) after the maximum number of logs have reached, since it depends on the rename to overwrite the existing log files (Line 556 of lib/ruby/1.8/logger.rb).
The 2 IRB sessions below shows the problem.
Ruby IRB:
irb(main):001:0> File.open('test1.txt', 'w') { |file| file.write('test1') }
=> 5
irb(main):002:0> File.open('test2.txt', 'w') { |file| file.write('test2') }
=> 5
irb(main):003:0> File.read('test2.txt')
=> "test2"
irb(main):004:0> File.rename('test1.txt', 'test2.txt')
=> 0
irb(main):005:0> File.read('test2.txt')
=> "test1"
irb(main):006:0> File.read('test1.txt')
Errno::ENOENT: No such file or directory - test1.txt
from (irb):6:in `read'
from (irb):6
from :0
irb(main):007:0>
JRuby jIRB:
irb(main):001:0> File.open('test1.txt', 'w') { |file| file.write('test1') }
=> 5
irb(main):002:0> File.open('test2.txt', 'w') { |file| file.write('test2') }
=> 5
irb(main):003:0> File.read('test2.txt')
=> "test2"
irb(main):004:0> File.rename('test1.txt', 'test2.txt')
=> 0
irb(main):005:0> File.read('test2.txt') # Expecting "test1"
=> "test2"
irb(main):006:0> File.read('test1.txt') # Expecting error
=> "test1"
irb(main):007:0>
Simple file rename test attached.