diff --git a/CHANGELOG.md b/CHANGELOG.md index b91c19fabe..0e1cdc48c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # v1.12 +## Release v1.12.4 - 2021/05/26 + +### Bug fix + +* in_tail: Fix a bug that refresh_watcher fails to handle file rotations + ## Release v1.12.3 - 2021/04/23 ### Enhancement diff --git a/lib/fluent/plugin/in_tail/position_file.rb b/lib/fluent/plugin/in_tail/position_file.rb index 88614d2802..faf27e95ee 100644 --- a/lib/fluent/plugin/in_tail/position_file.rb +++ b/lib/fluent/plugin/in_tail/position_file.rb @@ -248,6 +248,20 @@ def read_inode end end - TargetInfo = Struct.new(:path, :ino) + TargetInfo = Struct.new(:path, :ino) do + def ==(other) + return false unless other.is_a?(TargetInfo) + self.path == other.path + end + + def hash + self.path.hash + end + + def eql?(other) + return false unless other.is_a?(TargetInfo) + self.path == other.path + end + end end end diff --git a/lib/fluent/version.rb b/lib/fluent/version.rb index 7413ca114f..4325fde1f9 100644 --- a/lib/fluent/version.rb +++ b/lib/fluent/version.rb @@ -16,6 +16,6 @@ module Fluent - VERSION = '1.12.3' + VERSION = '1.12.4' end diff --git a/test/plugin/in_tail/test_position_file.rb b/test/plugin/in_tail/test_position_file.rb index eb07eeb4b9..0715ab2996 100644 --- a/test/plugin/in_tail/test_position_file.rb +++ b/test/plugin/in_tail/test_position_file.rb @@ -282,4 +282,58 @@ def build_files(file) assert_equal 2, f.read_inode end end + + sub_test_case "TargetInfo equality rules" do + sub_test_case "== operator" do + def test_equal + t1 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1234) + t2 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1235) + + assert_equal t1, t2 + end + + def test_not_equal + t1 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1234) + t2 = Fluent::Plugin::TailInput::TargetInfo.new("test2", 1234) + + assert_not_equal t1, t2 + end + end + + sub_test_case "eql? method" do + def test_eql? + t1 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1234) + t2 = Fluent::Plugin::TailInput::TargetInfo.new("test", 5321) + + assert do + t1.eql? t2 + end + end + + def test_not_eql? + t1 = Fluent::Plugin::TailInput::TargetInfo.new("test2", 1234) + t2 = Fluent::Plugin::TailInput::TargetInfo.new("test3", 1234) + + assert do + !t1.eql? t2 + end + end + end + + sub_test_case "hash" do + def test_equal + t1 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1234) + t2 = Fluent::Plugin::TailInput::TargetInfo.new("test", 7321) + + assert_equal t1.hash, t2.hash + end + + def test_not_equal + t1 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1234) + t2 = Fluent::Plugin::TailInput::TargetInfo.new("test2", 1234) + + assert_not_equal t1.hash, t2.hash + end + end + end end