Skip to content

Commit bbedd4f

Browse files
Silence msgpack warnings when detecting format
This silences a "ActiveSupport::MessagePack requires the msgpack gem" warning that can occur when using a non-`:message_pack` serializer and trying to detect the format of a serialized cache entry. `silence_warnings` is a blunt instrument, but this `require` is only for decoding legacy cache entries that were encoded using `:message_pack`, if any. (i.e. If `:message_pack` is currently being used as a serializer, then `SerializerWithFallback::[]` should have already loaded `active_support/message_pack`.) Therefore, it seems less hazardous to inadvertently silence other warnings that may occur when loading the file. Co-authored-by: Alex Ghiculescu <[email protected]>
1 parent 8049d79 commit bbedd4f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

activesupport/lib/active_support/cache/serializer_with_fallback.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
require "active_support/core_ext/kernel/reporting"
4+
35
module ActiveSupport
46
module Cache
57
module SerializerWithFallback # :nodoc:
@@ -156,7 +158,7 @@ def dumped?(dumped)
156158
private
157159
def available?
158160
return @available if defined?(@available)
159-
require "active_support/message_pack"
161+
silence_warnings { require "active_support/message_pack" }
160162
@available = true
161163
rescue LoadError
162164
@available = false

0 commit comments

Comments
 (0)