Skip to content

Commit 19fc734

Browse files
committed
Fix log rotation inter-process lock failed.
Issue only occurs in JRuby 9.3.0.0 and Windows and the full console output is: log rotation inter-process lock failed. D:\log.txt -> D:\log.txt.0: The process cannot access the file because it is being used by another process. log writing failed. closed stream log writing failed. closed stream ...
1 parent cdeddb2 commit 19fc734

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

lib/logger.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# A simple system for logging messages. See Logger for more documentation.
1212

1313
require 'monitor'
14+
require 'rbconfig'
1415

1516
require_relative 'logger/version'
1617
require_relative 'logger/formatter'

lib/logger/log_device.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def check_shift_log
135135
end
136136
end
137137

138-
if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
138+
if /mswin|mingw|cygwin/ =~ RbConfig::CONFIG['host_os']
139139
def lock_shift_log
140140
yield
141141
end

test/lib/core_assertions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def assert_separately(args, file = nil, line = nil, src, ignore_stderr: nil, **o
260260
line ||= loc.lineno
261261
end
262262
capture_stdout = true
263-
unless /mswin|mingw/ =~ RUBY_PLATFORM
263+
unless /mswin|mingw/ =~ RbConfig::CONFIG['host_os']
264264
capture_stdout = false
265265
opt[:out] = Test::Unit::Runner.output if defined?(Test::Unit::Runner)
266266
res_p, res_c = IO.pipe

test/logger/test_logdevice.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ def test_shifting_size_not_rotate_too_much
435435

436436
logdev1.write(message)
437437
assert_file.identical?(log, logdev1.dev)
438+
# NOTE: below assertion fails in JRuby 9.3 and TruffleRuby
438439
assert_file.identical?(log + ".0", logdev2.dev)
439440

440441
logdev2.write(message)
@@ -451,7 +452,7 @@ def test_shifting_size_not_rotate_too_much
451452
end
452453
ensure
453454
logdev0.close
454-
end unless /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
455+
end unless /mswin|mingw|cygwin/ =~ RbConfig::CONFIG['host_os']
455456

456457
def test_shifting_midnight
457458
Dir.mktmpdir do |tmpdir|

0 commit comments

Comments
 (0)