From cbcfec88a8c47c8aaa3126da1b88ccd79da73858 Mon Sep 17 00:00:00 2001 From: Holger Just Date: Wed, 2 Aug 2017 17:23:47 +0200 Subject: [PATCH] Synchronize FilterChain#to_s and FilterChain#inspect This ensures that any access to the internal @filters array is only done with an aquired lock to ensure data consistency. --- lib/rackstash/filter_chain.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/rackstash/filter_chain.rb b/lib/rackstash/filter_chain.rb index abaea8b..91d4bf3 100644 --- a/lib/rackstash/filter_chain.rb +++ b/lib/rackstash/filter_chain.rb @@ -227,8 +227,10 @@ module Rackstash # @return [String] a string representation of `self` def inspect - id_str = Object.instance_method(:to_s).bind(self).call[2..-2] - "#<#{id_str} #{self}>" + synchronize do + id_str = Object.instance_method(:to_s).bind(self).call[2..-2] + "#<#{id_str} #{self}>" + end end # @return [Integer] the number of elements in `self`. May be zero. @@ -259,7 +261,7 @@ module Rackstash # @return [String] an Array-compatible string representation of `self` def to_s - @filters.to_s + synchronize { @filters.to_s } end private