Skip to content
This repository has been archived by the owner on Jul 2, 2023. It is now read-only.

Commit

Permalink
Some array logic cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bud Byrd committed Sep 7, 2014
1 parent 06fb7f5 commit d3c1f0c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion application.properties
@@ -1,4 +1,5 @@
#Grails Metadata file
#Fri Oct 11 09:17:35 CDT 2013
#Fri Aug 29 15:48:11 PDT 2014
app.grails.version=2.1.1
app.name=rabbitmq-native
plugins.tomcat=2.1.1
12 changes: 7 additions & 5 deletions src/groovy/com/budjb/rabbitmq/ConnectionContext.groovy
Expand Up @@ -89,12 +89,12 @@ class ConnectionContext {
/**
* List of message consumers for this connection.
*/
List<DefaultGrailsMessageConsumerClass> consumers = []
List<DefaultGrailsMessageConsumerClass> consumers = new ArrayList<DefaultGrailsMessageConsumerClass>()

/**
* List of open channels in use by consumers.
*/
List<Channel> channels = []
List<Channel> channels = new ArrayList<Channel>()

/**
* Lazy-loaded connection to RabbitMQ.
Expand Down Expand Up @@ -199,6 +199,8 @@ class ConnectionContext {
return
}

stopConsumers()

log.debug("closing connection to the RabbitMQ server")
connection.close()
connection = null
Expand All @@ -217,16 +219,16 @@ class ConnectionContext {
* Stops all consumers associated with this connection.
*/
public void stopConsumers() {
if (channels) {
if (channels.size()) {
log.debug("closing RabbitMQ channels")
channels.each { channel ->
if (channel.isOpen()) {
channel.close()
}
}
channels = []
channels.clear()
}
consumers = []
consumers.clear()
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/groovy/com/budjb/rabbitmq/RabbitContext.groovy
Expand Up @@ -38,12 +38,12 @@ class RabbitContext {
/**
* List of current connection contexts.
*/
protected List<ConnectionContext> connections = []
protected List<ConnectionContext> connections = new ArrayList<ConnectionContext>()

/**
* A list of registered message converters.
*/
public List<MessageConverter> messageConverters = []
public List<MessageConverter> messageConverters = new ArrayList<MessageConverter>()

/**
* Loads and initializes the configuration.
Expand Down Expand Up @@ -112,10 +112,10 @@ class RabbitContext {

// Disconnect
connections*.closeConnection()
connections = []
connections.clear()

// Clear message converters
messageConverters = []
messageConverters.clear()
}

/**
Expand Down

0 comments on commit d3c1f0c

Please sign in to comment.