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 @@
</properties>
<body>
<release version="2.0" date="unreleased" description="JDK 1.5
based major release">
+ <action dev="tv" type="fix" issue="JCS-82" due-to="Nikunj Trivedi">
+ Use oos.writeUnshared() for LateralTCPSender
+ </action>
<action dev="tv" type="fix" issue="JCS-69" due-to="Michael
Stevens">
Ensure shutdown of LateralCacheMonitor
</action>
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 )
{