diff --git a/lib/fluent/plugin/in_tail.rb b/lib/fluent/plugin/in_tail.rb index 68c3bc476f..ae46483366 100644 --- a/lib/fluent/plugin/in_tail.rb +++ b/lib/fluent/plugin/in_tail.rb @@ -586,8 +586,7 @@ def initialize(path, log, &on_rotate) def on_notify begin - io = FileWrapper.open(@path) - stat = io.stat + stat = FileWrapper.stat(@path) inode = stat.ino fsize = stat.size rescue Errno::ENOENT @@ -599,13 +598,14 @@ def on_notify begin if @inode != inode || fsize < @fsize # rotated or truncated + begin + io = FileWrapper.open(@path) + rescue Errno::ENOENT + end @on_rotate.call(io) - io = nil end @inode = inode @fsize = fsize - ensure - io.close if io end rescue