jtaylor 02/05/14 12:28:12
Modified: src/java/org/apache/jcs/auxiliary/disk
AbstractDiskCache.java
Log:
Slightly better sync between removals and puts. I can't make the test fail, but
there are still potential places where things could break down. Probably either
need to sync on purgatory or pause the queue. The later is certainly the better
option.
Revision Changes Path
1.5 +21 -3
jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
Index: AbstractDiskCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractDiskCache.java 14 May 2002 17:44:40 -0000 1.4
+++ AbstractDiskCache.java 14 May 2002 19:28:12 -0000 1.5
@@ -87,7 +87,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Aaron Smuts</a>
* @author <a href="mailto:[EMAIL PROTECTED]">James Taylor</a>
- * @version $Id: AbstractDiskCache.java,v 1.4 2002/05/14 17:44:40 jtaylor Exp $
+ * @version $Id: AbstractDiskCache.java,v 1.5 2002/05/14 19:28:12 jtaylor Exp $
*/
public abstract class AbstractDiskCache implements AuxiliaryCache, Serializable
{
@@ -251,12 +251,21 @@
/**
* @see org.apache.jcs.engine.behavior.ICache#remove
+ *
+ * FIXME: This now updates the 'spoolable' property of the purgatory element
+ * for the given key to 'false', however to be really safe we should
+ * pause the event queue while in this method.
*/
public final boolean remove( Serializable key )
{
// Remove element from purgatory if it is there
- purgatory.remove( key );
+ PurgatoryElement pe = ( PurgatoryElement ) purgatory.remove( key );
+
+ if ( pe != null )
+ {
+ pe.setSpoolable( false );
+ }
// Remove from persistent store immediately
@@ -361,7 +370,8 @@
*
* NOTE: This checks if the element is a puratory element and behaves
* differently depending. However since we have control over how
- * elements are added to the cache event queue.
+ * elements are added to the cache event queue, that may not be needed
+ * ( they are always PurgatoryElements ).
*/
public void handlePut( ICacheElement element )
throws IOException
@@ -374,6 +384,14 @@
if ( element instanceof PurgatoryElement )
{
PurgatoryElement pe = ( PurgatoryElement ) element;
+
+ // If the element has already been removed from purgatory
+ // do nothing
+
+ if ( ! purgatory.contains( pe ) )
+ {
+ return;
+ }
element = pe.getCacheElement();
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>