Skip to content

Commit d6e06ea

Browse files
committed
Remove deprecated ActiveSupport::JSON::Encoding::CircularReferenceError.
1 parent c8019c0 commit d6e06ea

File tree

3 files changed

+4
-46
lines changed

3 files changed

+4
-46
lines changed

activesupport/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Remove deprecated `ActiveSupport::JSON::Encoding::CircularReferenceError`.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove deprecated methods `ActiveSupport::JSON::Encoding.encode_big_decimal_as_string=`
26
and `ActiveSupport::JSON::Encoding.encode_big_decimal_as_string`.
37

activesupport/lib/active_support/json/encoding.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,28 +112,6 @@ class << self
112112
# Sets the encoder used by Rails to encode Ruby objects into JSON strings
113113
# in +Object#to_json+ and +ActiveSupport::JSON.encode+.
114114
attr_accessor :json_encoder
115-
116-
# Deprecate CircularReferenceError
117-
def const_missing(name)
118-
if name == :CircularReferenceError
119-
message = "The JSON encoder in Rails 4.1 no longer offers protection from circular references. " \
120-
"You are seeing this warning because you are rescuing from (or otherwise referencing) " \
121-
"ActiveSupport::Encoding::CircularReferenceError. In the future, this error will be " \
122-
"removed from Rails. You should remove these rescue blocks from your code and ensure " \
123-
"that your data structures are free of circular references so they can be properly " \
124-
"serialized into JSON.\n\n" \
125-
"For example, the following Hash contains a circular reference to itself:\n" \
126-
" h = {}\n" \
127-
" h['circular'] = h\n" \
128-
"In this case, calling h.to_json would not work properly."
129-
130-
ActiveSupport::Deprecation.warn message
131-
132-
SystemStackError
133-
else
134-
super
135-
end
136-
end
137115
end
138116

139117
self.use_standard_json_time_format = true

activesupport/test/json/encoding_test.rb

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -176,30 +176,6 @@ def test_wide_utf8_roundtrip
176176
assert_equal "𐒑", decoded_hash['string']
177177
end
178178

179-
def test_exception_raised_when_encoding_circular_reference_in_array
180-
a = [1]
181-
a << a
182-
assert_deprecated do
183-
assert_raise(ActiveSupport::JSON::Encoding::CircularReferenceError) { ActiveSupport::JSON.encode(a) }
184-
end
185-
end
186-
187-
def test_exception_raised_when_encoding_circular_reference_in_hash
188-
a = { :name => 'foo' }
189-
a[:next] = a
190-
assert_deprecated do
191-
assert_raise(ActiveSupport::JSON::Encoding::CircularReferenceError) { ActiveSupport::JSON.encode(a) }
192-
end
193-
end
194-
195-
def test_exception_raised_when_encoding_circular_reference_in_hash_inside_array
196-
a = { :name => 'foo', :sub => [] }
197-
a[:sub] << a
198-
assert_deprecated do
199-
assert_raise(ActiveSupport::JSON::Encoding::CircularReferenceError) { ActiveSupport::JSON.encode(a) }
200-
end
201-
end
202-
203179
def test_hash_key_identifiers_are_always_quoted
204180
values = {0 => 0, 1 => 1, :_ => :_, "$" => "$", "a" => "a", :A => :A, :A0 => :A0, "A0B" => "A0B"}
205181
assert_equal %w( "$" "A" "A0" "A0B" "_" "a" "0" "1" ).sort, object_keys(ActiveSupport::JSON.encode(values))

0 commit comments

Comments
 (0)