Return-Path: Delivered-To: apmail-geronimo-activemq-commits-archive@www.apache.org Received: (qmail 27062 invoked from network); 6 Mar 2006 14:26:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Mar 2006 14:26:28 -0000 Received: (qmail 94821 invoked by uid 500); 6 Mar 2006 14:27:13 -0000 Delivered-To: apmail-geronimo-activemq-commits-archive@geronimo.apache.org Received: (qmail 94788 invoked by uid 500); 6 Mar 2006 14:27:13 -0000 Mailing-List: contact activemq-commits-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-commits@geronimo.apache.org Received: (qmail 94779 invoked by uid 99); 6 Mar 2006 14:27:13 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Mar 2006 06:27:13 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 06 Mar 2006 06:27:12 -0800 Received: (qmail 26829 invoked by uid 65534); 6 Mar 2006 14:26:02 -0000 Message-ID: <20060306142602.26827.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r383546 - /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/OpenWireFormat.java Date: Mon, 06 Mar 2006 14:26:00 -0000 To: activemq-commits@geronimo.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: chirino Date: Mon Mar 6 06:25:36 2006 New Revision: 383546 URL: http://svn.apache.org/viewcvs?rev=383546&view=rev Log: Protect against cache overwrites. Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/OpenWireFormat.java Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/OpenWireFormat.java URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/OpenWireFormat.java?rev=383546&r1=383545&r2=383546&view=diff ============================================================================== --- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/OpenWireFormat.java (original) +++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/OpenWireFormat.java Mon Mar 6 06:25:36 2006 @@ -400,13 +400,25 @@ nextMarshallCacheIndex=0; } - marshallCache[i] = o; - Short index = new Short(i); - marshallCacheMap.put(o, index); - return index; + // We can only cache that item if there is space left. + if( marshallCacheMap.size() < MARSHAL_CACHE_SIZE ) { + marshallCache[i] = o; + Short index = new Short(i); + marshallCacheMap.put(o, index); + return index; + } else { + // Use -1 to indicate that the value was not cached due to cache being full. + return new Short((short)-1); + } } public void setInUnmarshallCache(short index, DataStructure o) { + + // There was no space left in the cache, so we can't + // put this in the cache. + if( index == -1 ) + return; + unmarshallCache[index]=o; }