Return-Path: Delivered-To: apmail-geronimo-activemq-dev-archive@www.apache.org Received: (qmail 24976 invoked from network); 23 Dec 2005 17:37:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 23 Dec 2005 17:37:21 -0000 Received: (qmail 61218 invoked by uid 500); 23 Dec 2005 17:37:21 -0000 Delivered-To: apmail-geronimo-activemq-dev-archive@geronimo.apache.org Received: (qmail 61151 invoked by uid 500); 23 Dec 2005 17:37:20 -0000 Mailing-List: contact activemq-dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-dev@geronimo.apache.org Delivered-To: mailing list activemq-dev@geronimo.apache.org Received: (qmail 61133 invoked by uid 99); 23 Dec 2005 17:37:20 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Dec 2005 09:37:20 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [205.134.237.44] (HELO hiramchirino.com) (205.134.237.44) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Dec 2005 09:37:19 -0800 Received: from [172.16.224.243] (hiramchirino.com [127.0.0.1]) (authenticated) by hiramchirino.com (8.11.6/8.11.6) with ESMTP id jBNHaq032257; Fri, 23 Dec 2005 09:36:52 -0800 In-Reply-To: <20051223094801.34751.qmail@minotaur.apache.org> References: <20051223094801.34751.qmail@minotaur.apache.org> Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <4A89BE96-080B-4E79-B34E-70E470A8C998@hiramchirino.com> Cc: activemq-commits@geronimo.apache.org Content-Transfer-Encoding: 7bit From: Hiram Chirino Subject: Re: svn commit: r358785 - /incubator/activemq/trunk/activemq-core/src/main/java/org/activemq/broker/region/PrefetchSubscription.java Date: Fri, 23 Dec 2005 12:37:08 -0500 To: activemq-dev@geronimo.apache.org X-Mailer: Apple Mail (2.746.2) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi Adrian, doing a getMessage() before incrementReferenceCount() is dangerous since the message could have been swapped out and the call to getMessage() will return null. Yes, I know there is a null check to see if the message is null, but that should only happen if the message was expired. Right now I think it's possible that we are going to have cases of where messages get swapped out and this code is going to think that the message has been expired. Regards, Hiram On Dec 23, 2005, at 4:48 AM, aco@apache.org wrote: > Author: aco > Date: Fri Dec 23 01:47:47 2005 > New Revision: 358785 > > URL: http://svn.apache.org/viewcvs?rev=358785&view=rev > Log: > 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. > > Modified: > incubator/activemq/trunk/activemq-core/src/main/java/org/ > activemq/broker/region/PrefetchSubscription.java > > Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/ > activemq/broker/region/PrefetchSubscription.java > URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/ > activemq-core/src/main/java/org/activemq/broker/region/ > PrefetchSubscription.java?rev=358785&r1=358784&r2=358785&view=diff > ====================================================================== > ======== > --- incubator/activemq/trunk/activemq-core/src/main/java/org/ > activemq/broker/region/PrefetchSubscription.java (original) > +++ incubator/activemq/trunk/activemq-core/src/main/java/org/ > activemq/broker/region/PrefetchSubscription.java Fri Dec 23 > 01:47:47 2005 > @@ -239,19 +239,19 @@ > > 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) ) { > > MessageDispatch md = createMessageDispatch(node, > message); > dispatched.addLast(node); > + > + node.incrementReferenceCount(); > + incrementPreloadSize(node.getMessage().getSize()); > > if( info.isDispatchAsync() ) { > md.setConsumer(new Runnable(){ >