Skip to content

Commit

Permalink
Close pull request review #24791986 by removing specs supporting conn…
Browse files Browse the repository at this point in the history
…ection reopen after it has been manually closed

Change ConnectionManuallyClosed exception name to ConnectionAlreadyClosed
Minor improvements
  • Loading branch information
madAle committed Mar 2, 2017
1 parent ad67595 commit 503367b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lib/bunny/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def initialize(frame)
end
end

class ConnectionManuallyClosed < Exception
class ConnectionAlreadyClosed < Exception
def initialize
super('Connection has been manually closed. Call #start to reopen it')
super('Connection has been already closed')
end
end

Expand Down
3 changes: 2 additions & 1 deletion lib/bunny/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def transport_write_timeout
# @return [Bunny::Channel] Newly opened channel
def create_channel(n = nil, consumer_pool_size = 1, consumer_pool_abort_on_exception = false, consumer_pool_shutdown_timeout = 60)
raise ArgumentError, "channel number 0 is reserved in the protocol and cannot be used" if 0 == n
raise ConnectionManuallyClosed if manually_closed?
raise ConnectionAlreadyClosed if manually_closed?

@channel_mutex.synchronize do
if n && (ch = @channels[n])
Expand Down Expand Up @@ -409,6 +409,7 @@ def closed?
@status_mutex.synchronize { @status == :closed }
end

# @return [Boolean] true if this AMQP 0.9.1 connection has been programmatically closed
def manually_closed?
@status_mutex.synchronize { @manually_closed == true }
end
Expand Down
21 changes: 1 addition & 20 deletions spec/issues/issue465_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,7 @@
it 'should raise an exception' do
expect {
connection.create_channel
}.to raise_error(Bunny::ConnectionManuallyClosed)
end
end

describe '#start' do
it 'should be possible to reopen it' do
connection.start
expect(connection.status).to eq :open
end
end

context 'and reopened' do
before :each do
connection.start
end

describe '#create_channel' do
it 'should create a new channel' do
expect(connection.create_channel).to be_kind_of(Bunny::Channel)
end
}.to raise_error(Bunny::ConnectionAlreadyClosed)
end
end
end
Expand Down

0 comments on commit 503367b

Please sign in to comment.