Skip to content

Commit

Permalink
Merge pull request #724 from pact-foundation/fix/rubocop-error-on-pg-…
Browse files Browse the repository at this point in the history
…advisory-lock

fix: result will not be returned from ensure incase of an error also result variable is unused
  • Loading branch information
pahnin authored Sep 18, 2024
2 parents fb73e7e + 4a0a4fa commit 7be083c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/sequel/extensions/pg_advisory_lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# locks to be registered because different threads running the same code
# should not cause a Sequel::Error to be raised.
# Also, I wanted it to use Concurrent::Hash for multi-threaded environments.
# Made minor change in begin ensure block in with_advisory_lock method.

require "sequel"
require "zlib"
Expand Down Expand Up @@ -57,10 +58,9 @@ def with_advisory_lock(name, id = nil)
synchronize do
if get(Sequel.function(lock_function, *function_params))
begin
result = yield
yield
ensure
get(Sequel.function(UNLOCK_FUNCTION, *function_params))
result
end
end
end
Expand Down

0 comments on commit 7be083c

Please sign in to comment.