Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8A1E77067 for ; Sun, 30 Oct 2011 21:02:47 +0000 (UTC) Received: (qmail 88970 invoked by uid 500); 30 Oct 2011 21:02:47 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 88881 invoked by uid 500); 30 Oct 2011 21:02:47 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 88874 invoked by uid 99); 30 Oct 2011 21:02:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Oct 2011 21:02:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Oct 2011 21:02:44 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 147362388A6E for ; Sun, 30 Oct 2011 21:02:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1195243 - in /commons/proper/jcs/trunk/src: changes/changes.xml java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java Date: Sun, 30 Oct 2011 21:02:22 -0000 To: commits@commons.apache.org From: tv@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111030210223.147362388A6E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tv Date: Sun Oct 30 21:02:22 2011 New Revision: 1195243 URL: http://svn.apache.org/viewvc?rev=1195243&view=rev Log: Use oos.writeUnshared(), remove scheduled OOS reset. Fixes JCS-82 Modified: commons/proper/jcs/trunk/src/changes/changes.xml commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java Modified: commons/proper/jcs/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/changes/changes.xml?rev=1195243&r1=1195242&r2=1195243&view=diff ============================================================================== --- commons/proper/jcs/trunk/src/changes/changes.xml (original) +++ commons/proper/jcs/trunk/src/changes/changes.xml Sun Oct 30 21:02:22 2011 @@ -20,6 +20,9 @@ + + Use oos.writeUnshared() for LateralTCPSender + Ensure shutdown of LateralCacheMonitor Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java?rev=1195243&r1=1195242&r2=1195243&view=diff ============================================================================== --- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java (original) +++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java Sun Oct 30 21:02:22 2011 @@ -58,23 +58,9 @@ public class LateralTCPSender /** The socket connection with the server. */ private Socket socket; - /** counter, for periodic OOS reset. */ - int counter = 0; - /** how many messages sent */ private int sendCnt = 0; - // reset the ObjectOutputStream every 70 calls - // private static final int RESET_FREQUENCY = 70; - // Perhaps we need to reset every time until we move to jdk 1.4 - // then we can call writeUnshared to make sure - // that the object definetely gets across and not - // a stream cached version. - // I can't replicate an issue that was reported, so I'm not changing the - // reset frequency for now. - /** How often we need to reset the stream. */ - private final static int RESET_FREQUENCY = 70; - /** Use to synchronize multiple threads that may be trying to get. */ private final Object getLock = new int[0]; @@ -216,19 +202,8 @@ public class LateralTCPSender { try { - oos.writeObject( led ); + oos.writeUnshared( led ); oos.flush(); - if ( ++counter >= RESET_FREQUENCY ) - { - counter = 0; - // Failing to reset the object output stream every now and - // then creates a serious memory leak. - if ( log.isDebugEnabled() ) - { - log.debug( "Doing oos.reset()" ); - } - oos.reset(); - } } catch ( IOException e ) { @@ -292,7 +267,7 @@ public class LateralTCPSender } // write object to listener - oos.writeObject( led ); + oos.writeUnshared( led ); oos.flush(); try @@ -313,15 +288,6 @@ public class LateralTCPSender { log.error( e ); } - - if ( ++counter >= RESET_FREQUENCY ) - { - counter = 0; - // Failing to reset the object output stream every now - // and then creates a serious memory leak. - log.info( "Doing oos.reset()" ); - oos.reset(); - } } catch ( IOException e ) {