From 1e32fd797b53f6f490b9119841d255ac5caf0fbd Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Sun, 18 Jan 2015 11:01:03 -0800 Subject: [PATCH] Remove tap usage, comment this necessary complexity --- lib/connection_pool.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/connection_pool.rb b/lib/connection_pool.rb index 9478573..8c25510 100644 --- a/lib/connection_pool.rb +++ b/lib/connection_pool.rb @@ -53,12 +53,15 @@ class ConnectionPool end def with(options = {}) - success = false # hoisted + # Connections can become corrupted via Timeout::Error. Discard + # any connection whose usage after checkout does not finish as expected. + # See #67 + success = false conn = checkout(options) begin - (yield conn).tap do - success = true # means the connection wasn't interrupted - end + result = yield conn + success = true # means the connection wasn't interrupted + result ensure if success # everything is roses, we can safely check the connection back in