mirror of https://github.com/apache/activemq.git
Postpone incrementing of reference count and preload size, only after we are sure that the message will be dispatched by the current subscription. This is to prevent a memory leak type of scenario.
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@358785 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c834d38b8f
commit
29a6b9d1f6
|
@ -239,13 +239,10 @@ abstract public class PrefetchSubscription extends AbstractSubscription {
|
|||
|
||||
private void dispatch(final MessageReference node) throws IOException {
|
||||
|
||||
node.incrementReferenceCount();
|
||||
|
||||
final Message message = node.getMessage();
|
||||
if( message == null ) {
|
||||
return;
|
||||
}
|
||||
incrementPreloadSize(node.getMessage().getSize());
|
||||
|
||||
// Make sure we can dispatch a message.
|
||||
if( canDispatch(node) ) {
|
||||
|
@ -253,6 +250,9 @@ abstract public class PrefetchSubscription extends AbstractSubscription {
|
|||
MessageDispatch md = createMessageDispatch(node, message);
|
||||
dispatched.addLast(node);
|
||||
|
||||
node.incrementReferenceCount();
|
||||
incrementPreloadSize(node.getMessage().getSize());
|
||||
|
||||
if( info.isDispatchAsync() ) {
|
||||
md.setConsumer(new Runnable(){
|
||||
public void run() {
|
||||
|
|
Loading…
Reference in New Issue