From 8536ebeefad411ffd1b476c6b499aaec84efea80 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sun, 27 Aug 2017 21:31:48 +0900 Subject: Fix `can't modify frozen String` error in `DebugLocks` Without this, `DebugLocks` middleware raises an error as follwing: ``` Puma caught this error: can't modify frozen String (RuntimeError) actionpack/lib/action_dispatch/middleware/debug_locks.rb:97:in `block in render_details' actionpack/lib/action_dispatch/middleware/debug_locks.rb:64:in `each' actionpack/lib/action_dispatch/middleware/debug_locks.rb:64:in `map' actionpack/lib/action_dispatch/middleware/debug_locks.rb:64:in `render_details' actionpack/lib/action_dispatch/middleware/debug_locks.rb:37:in `call' railties/lib/rails/engine.rb:524:in `call' ``` --- actionpack/lib/action_dispatch/middleware/debug_locks.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/middleware/debug_locks.rb b/actionpack/lib/action_dispatch/middleware/debug_locks.rb index c61a941010..541fb25b6c 100644 --- a/actionpack/lib/action_dispatch/middleware/debug_locks.rb +++ b/actionpack/lib/action_dispatch/middleware/debug_locks.rb @@ -63,19 +63,19 @@ module ActionDispatch str = threads.map do |thread, info| if info[:exclusive] - lock_state = "Exclusive" + lock_state = "Exclusive".dup elsif info[:sharing] > 0 - lock_state = "Sharing" + lock_state = "Sharing".dup lock_state << " x#{info[:sharing]}" if info[:sharing] > 1 else - lock_state = "No lock" + lock_state = "No lock".dup end if info[:waiting] lock_state << " (yielded share)" end - msg = "Thread #{info[:index]} [0x#{thread.__id__.to_s(16)} #{thread.status || 'dead'}] #{lock_state}\n" + msg = "Thread #{info[:index]} [0x#{thread.__id__.to_s(16)} #{thread.status || 'dead'}] #{lock_state}\n".dup if info[:sleeper] msg << " Waiting in #{info[:sleeper]}" -- cgit v1.2.3 From fe4753fac87317180c1dadfa07112bbe9f72aaf5 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Mon, 28 Aug 2017 10:59:35 +0900 Subject: Fix `warning: shadowing outer local variable` This fixes following warnings: ``` actionpack/lib/action_dispatch/middleware/debug_locks.rb:46: warning: shadowing outer local variable - threads ``` --- actionpack/lib/action_dispatch/middleware/debug_locks.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/middleware/debug_locks.rb b/actionpack/lib/action_dispatch/middleware/debug_locks.rb index 541fb25b6c..03760438f7 100644 --- a/actionpack/lib/action_dispatch/middleware/debug_locks.rb +++ b/actionpack/lib/action_dispatch/middleware/debug_locks.rb @@ -43,7 +43,7 @@ module ActionDispatch private def render_details(req) - threads = ActiveSupport::Dependencies.interlock.raw_state do |threads| + threads = ActiveSupport::Dependencies.interlock.raw_state do |raw_threads| # The Interlock itself comes to a complete halt as long as this block # is executing. That gives us a more consistent picture of everything, # but creates a pretty strong Observer Effect. @@ -53,12 +53,12 @@ module ActionDispatch # strictly diagnostic tool (to be used when something has gone wrong), # and not for any sort of general monitoring. - threads.each.with_index do |(thread, info), idx| + raw_threads.each.with_index do |(thread, info), idx| info[:index] = idx info[:backtrace] = thread.backtrace end - threads + raw_threads end str = threads.map do |thread, info| -- cgit v1.2.3