You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2010/06/03 23:29:09 UTC
svn commit: r951165 -
/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
Author: ritchiem
Date: Thu Jun 3 21:29:09 2010
New Revision: 951165
URL: http://svn.apache.org/viewvc?rev=951165&view=rev
Log:
QPID-2633 : Move destinationConsumer count logic to before the consumer is registered.
Modified:
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java?rev=951165&r1=951164&r2=951165&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java Thu Jun 3 21:29:09 2010
@@ -1835,12 +1835,6 @@ public abstract class AMQSession<C exten
throw ex;
}
- synchronized (destination)
- {
- _destinationConsumerCount.putIfAbsent(destination, new AtomicInteger());
- _destinationConsumerCount.get(destination).incrementAndGet();
- }
-
return consumer;
}
}, _connection).execute();
@@ -1869,9 +1863,15 @@ public abstract class AMQSession<C exten
Destination dest = consumer.getDestination();
synchronized (dest)
{
- if (_destinationConsumerCount.get(dest).decrementAndGet() == 0)
+ // Provide additional NPE check
+ // This would occur if the consumer was closed before it was
+ // fully opened.
+ if (_destinationConsumerCount.get(dest) != null)
{
- _destinationConsumerCount.remove(dest);
+ if (_destinationConsumerCount.get(dest).decrementAndGet() == 0)
+ {
+ _destinationConsumerCount.remove(dest);
+ }
}
}
@@ -2328,6 +2328,13 @@ public abstract class AMQSession<C exten
// we must register the consumer in the map before we actually start listening
_consumers.put(tagId, consumer);
+ synchronized (consumer.getDestination())
+ {
+ _destinationConsumerCount.putIfAbsent(consumer.getDestination(), new AtomicInteger());
+ _destinationConsumerCount.get(consumer.getDestination()).incrementAndGet();
+ }
+
+
try
{
sendConsume(consumer, queueName, protocolHandler, nowait, messageSelector, tagId);
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org