Skip to content

Commit

Permalink
Remove unnecessary begin/end
Browse files Browse the repository at this point in the history
  • Loading branch information
camelpunch committed Jun 12, 2016
1 parent 7a9352d commit ce94a6a
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions lib/bunny/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -668,30 +668,28 @@ def recovering_from_network_failure?

# @private
def recover_from_network_failure
begin
sleep @network_recovery_interval
@logger.debug "About to start connection recovery..."
sleep @network_recovery_interval
@logger.debug "About to start connection recovery..."

self.initialize_transport
self.initialize_transport

@logger.warn "Retrying connection on next host in line: #{@transport.host}:#{@transport.port}"
self.start
@logger.warn "Retrying connection on next host in line: #{@transport.host}:#{@transport.port}"
self.start

if open?
@recovering_from_network_failure = false
if open?
@recovering_from_network_failure = false

recover_channels
end
rescue HostListDepleted
reset_address_index
retry
rescue TCPConnectionFailedForAllHosts, TCPConnectionFailed, AMQ::Protocol::EmptyResponseError => e
@logger.warn "TCP connection failed, reconnecting in #{@network_recovery_interval} seconds"
sleep @network_recovery_interval
if should_retry_recovery?
@recovery_attempts -= 1 if @recovery_attempts
retry if recoverable_network_failure?(e)
end
recover_channels
end
rescue HostListDepleted
reset_address_index
retry
rescue TCPConnectionFailedForAllHosts, TCPConnectionFailed, AMQ::Protocol::EmptyResponseError => e
@logger.warn "TCP connection failed, reconnecting in #{@network_recovery_interval} seconds"
sleep @network_recovery_interval
if should_retry_recovery?
@recovery_attempts -= 1 if @recovery_attempts
retry if recoverable_network_failure?(e)
end
end

Expand Down

0 comments on commit ce94a6a

Please sign in to comment.