File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ * Make ActiveSupport::BacktraceCleaner copy filters and silencers on dup and clone
2
+
3
+ Previously the copy would still share the internal silencers and filters array,
4
+ causing state to leak.
5
+
6
+ * Jean Boussier*
7
+
1
8
* Updating Astana with Western Kazakhstan TZInfo identifier
2
9
3
10
* Damian Nelson*
Original file line number Diff line number Diff line change @@ -110,6 +110,11 @@ def remove_filters!
110
110
private
111
111
FORMATTED_GEMS_PATTERN = /\A [^\/ ]+ \( [\w .]+\) /
112
112
113
+ def initialize_copy ( _other )
114
+ @filters = @filters . dup
115
+ @silencers = @silencers . dup
116
+ end
117
+
113
118
def add_gem_filter
114
119
gems_paths = ( Gem . path | [ Gem . default_dir ] ) . map { |p | Regexp . escape ( p ) }
115
120
return if gems_paths . empty?
Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ def setup
22
22
test "backtrace should contain unaltered lines if they don't match a filter" do
23
23
assert_equal "/my/other_prefix/my/class.rb" , @bc . clean ( [ "/my/other_prefix/my/class.rb" ] ) . first
24
24
end
25
+
26
+ test "#dup also copy filters" do
27
+ copy = @bc . dup
28
+ @bc . add_filter { |line | line . gsub ( "/other/prefix/" , "" ) }
29
+
30
+ assert_equal "my/class.rb" , @bc . clean ( [ "/other/prefix/my/class.rb" ] ) . first
31
+ assert_equal "/other/prefix/my/class.rb" , copy . clean ( [ "/other/prefix/my/class.rb" ] ) . first
32
+ end
25
33
end
26
34
27
35
class BacktraceCleanerSilencerTest < ActiveSupport ::TestCase
@@ -40,6 +48,14 @@ def setup
40
48
@bc . remove_silencers!
41
49
assert_equal [ "/mongrel/stuff.rb" ] , @bc . clean ( [ "/mongrel/stuff.rb" ] )
42
50
end
51
+
52
+ test "#dup also copy silencers" do
53
+ copy = @bc . dup
54
+
55
+ @bc . add_silencer { |line | line . include? ( "puma" ) }
56
+ assert_equal [ ] , @bc . clean ( [ "/puma/stuff.rb" ] )
57
+ assert_equal [ "/puma/stuff.rb" ] , copy . clean ( [ "/puma/stuff.rb" ] )
58
+ end
43
59
end
44
60
45
61
class BacktraceCleanerMultipleSilencersTest < ActiveSupport ::TestCase
You can’t perform that action at this time.
0 commit comments