diff options
author | Dan Kubb <dan.kubb@gmail.com> | 2015-03-25 20:54:56 -0700 |
---|---|---|
committer | Dan Kubb <dan.kubb@gmail.com> | 2015-03-25 20:54:56 -0700 |
commit | 41b2b3764f1f093c9a7f40fbbe2686412b83f2dc (patch) | |
tree | e0c43e98caf5fc5cf35aa1730b0b1bc0e1413388 /test/spec_lock.rb | |
parent | a324b9294fb7e2846e57d62e6330b4d862ae906b (diff) | |
download | rack-41b2b3764f1f093c9a7f40fbbe2686412b83f2dc.tar.gz |
Fix Rack::Lock to handle unexpected exceptions
* If an exception occurs after @app#call but before the response can be
returned then the mutex should be unlocked.
Diffstat (limited to 'test/spec_lock.rb')
-rw-r--r-- | test/spec_lock.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/spec_lock.rb b/test/spec_lock.rb index 099e806c..2ed44b92 100644 --- a/test/spec_lock.rb +++ b/test/spec_lock.rb @@ -187,4 +187,12 @@ describe Rack::Lock do response = app.call(Rack::MockRequest.env_for("/"))[2] response.env['rack.multithread'].should.equal false end + + should "unlock if an exception occurs before returning" do + lock = Lock.new + env = Rack::MockRequest.env_for("/") + app = lock_app(proc { [].freeze }, lock) + lambda { app.call(env) }.should.raise(Exception) + lock.synchronized.should.equal false + end end |