Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate reporting methods for silencing output as they aren't thread safe #13392

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions activesupport/lib/active_support/core_ext/kernel/reporting.rb
Expand Up @@ -31,9 +31,13 @@ def with_warnings(flag)

# For compatibility
def silence_stderr #:nodoc:
ActiveSupport::Deprecation.warn(
"#silence_stderr is deprecated and will be removed in the next release"
) #not thread-safe
silence_stream(STDERR) { yield }
end

# Deprecated : this method is not thread safe
# Silences any stream for the duration of the block.
#
# silence_stream(STDOUT) do
Expand Down Expand Up @@ -80,6 +84,9 @@ def suppress(*exception_classes)
# stream = capture(:stderr) { system('echo error 1>&2') }
# stream # => "error\n"
def capture(stream)
ActiveSupport::Deprecation.warn(
"#capture(stream) is deprecated and will be removed in the next release"
) #not thread-safe
stream = stream.to_s
captured_stream = Tempfile.new(stream)
stream_io = eval("$#{stream}")
Expand All @@ -101,6 +108,9 @@ def capture(stream)
#
# quietly { system 'bundle install' }
def quietly
ActiveSupport::Deprecation.warn(
"#quietly is deprecated and will be removed in the next release"
) #not thread-safe
silence_stream(STDOUT) do
silence_stream(STDERR) do
yield
Expand Down