Skip to content

Commit

Permalink
Prevent mismatched checkout/checkin
Browse files Browse the repository at this point in the history
Checkout can raise an exception if there is an error pulling connections
from the pool. In that case, we must not try to perform a checkin
because that will raise a new exception and mask the error caused by the
checkout.
  • Loading branch information
evanphx committed Feb 24, 2017
1 parent df0dc18 commit 9593cc6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/vault/persistent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,10 @@ def connection_for uri

raise Error, "host down: #{address}:#{port}"
ensure
@pool.checkin net_http_args
# Only perform checkin if we successfully checked a connection out
if connection
@pool.checkin net_http_args
end
end

##
Expand Down

0 comments on commit 9593cc6

Please sign in to comment.