dlr 2003/02/05 16:37:59
Modified: src/java/org/apache/jcs/engine/memory
AbstractMemoryCache.java
src/java/org/apache/jcs/engine/control/group
GroupAttrName.java
Log:
* src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java
removeAll(): When re-assigning the "map" instance field, use a
Hashtable (as in the constructor) rather than an unsynchronized
HashMap.
* src/java/org/apache/jcs/engine/control/group/GroupAttrName.java
hashString: New member used to create the hash code and implement
equality checking.
GroupAttrName(GroupId, Object): Added assignment of new "hashString"
field based on the "groupId" and "attrName" parameters.
equals(Object): Added JavaDoc. Dropped use of local GroupAttrName
reference "to". Implemented equality check using the new
"hashString" field so that it matches up with hashCode(), allowing
this object to be found in a Map (serious bug fix).
hashCode(): Re-implemented hash code generation using the new
"hashString" field.
Submitted by: Todd Enersen <[EMAIL PROTECTED]>
Revision Changes Path
1.3 +2 -2
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java
Index: AbstractMemoryCache.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -u -r1.2 -r1.3
--- AbstractMemoryCache.java 27 Jul 2002 06:39:51 -0000 1.2
+++ AbstractMemoryCache.java 6 Feb 2003 00:37:59 -0000 1.3
@@ -158,7 +158,7 @@
public void removeAll()
throws IOException
{
- map = new HashMap();
+ map = new Hashtable();
}
/**
1.3 +10 -5
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/group/GroupAttrName.java
Index: GroupAttrName.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/group/GroupAttrName.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -u -r1.2 -r1.3
--- GroupAttrName.java 6 Jun 2002 05:27:46 -0000 1.2
+++ GroupAttrName.java 6 Feb 2003 00:37:59 -0000 1.3
@@ -15,6 +15,7 @@
/** Description of the Field */
public final GroupId groupId;
public final Object attrName;
+ private String hashString;
private String toString;
/**
@@ -27,31 +28,35 @@
{
this.groupId = groupId;
this.attrName = attrName;
-
if ( groupId == null || attrName == null )
{
throw new IllegalArgumentException( "groupId " + groupId +
" and attrName " + attrName + ", must not be null." );
}
+ this.hashString = groupId.toString() + attrName.toString();
}
- /** Description of the Method */
+ /**
+ * Tests object equality.
+ *
+ * @param obj The <code>GroupAttrName</code> instance to test.
+ * @return Whether equal.
+ */
public boolean equals( Object obj )
{
if ( obj == null || !( obj instanceof GroupAttrName ) )
{
return false;
}
- GroupAttrName to = ( GroupAttrName ) obj;
- return groupId.equals( to.groupId ) && attrName.equals( to.attrName );
+ return hashString.equals( ((GroupAttrName) obj).hashString );
}
/** Description of the Method */
public int hashCode()
{
- return groupId.hashCode() ^ attrName.hashCode();
+ return hashString.hashCode();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]