SF-167401 changed key generation for ROT hashmaps to avoid collisions and random gc of pushed out objects

This commit is contained in:
clay_shooter
2007-03-10 13:39:37 +00:00
parent 344efcfa6f
commit 3a2e9429f3
2 changed files with 10 additions and 37 deletions

View File

@@ -25,7 +25,7 @@
<td width="13%" valign="top">1504120 </td>
<td width="87%" valign="top">Microsoft 2003 Server crashes. Server crashes on MS 2003 Server have been reported over time.
Some users have had say that Jacob must be built on MS2003 Server to run reliably.
The Jacob distribution on Sourceforge is built on Windows XP SP2.</td>
The Jacob distribution on Sourceforge is built on Windows XP SP2 (this item is soley informationional)</td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
@@ -34,6 +34,12 @@
<tr>
<td width="100%" colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">1674015</td>
<td width="87%" valign="top">ROT hashmap handling when autogc=no (default) can lead to key collisions
in hashmap. This causes objects to be garbage finalized when they shouldn't be resulting in vm failures
with large (large) numbers of objects. </td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>

View File

@@ -112,12 +112,7 @@ public abstract class ROT {
JacobObject.debug( "ROT: " + tab.keySet().size() + " objects to clear in this thread " );
}
// walk the values
Iterator it;
if ( USE_AUTOMATIC_GARBAGE_COLLECTION ) {
it = tab.keySet().iterator();
} else {
it = tab.values().iterator();
}
Iterator it = tab.keySet().iterator();
while ( it.hasNext() ) {
JacobObject o = (JacobObject) it.next();
if ( o != null
@@ -153,34 +148,6 @@ public abstract class ROT {
}
}
/**
* generates the key used to insert object into the thread's list of objects.
* @param targetMap the map we need the key for. Used to make sure we create a compatabile key
* @param o JacobObject we need key for
* @return some key compatabile with hashmaps
*/
protected static Object getMapKey( Map targetMap, JacobObject o ) {
if ( targetMap instanceof WeakHashMap ) {
return o;
} else {
return new Integer( o.hashCode() );
}
}
/**
* generates the object used to insert object into the thread's list of objects.
* @param targetMap the map we need the key for. Used to make sure we create a compatabile key
* @param o JacobObject we need key for
* @return some compatabile with hashmaps (null for weak has map)
*/
protected static Object getMapValue( Map targetMap, JacobObject o ) {
if ( targetMap instanceof WeakHashMap ) {
return null;
} else {
return o;
}
}
/**
* @deprecated the java model leave the responsibility of clearing up objects
* to the Garbage Collector. Our programming model should not require that the
@@ -193,7 +160,7 @@ public abstract class ROT {
String t_name = Thread.currentThread().getName();
Map tab = (Map) rot.get( t_name );
if ( tab != null ) {
tab.remove( getMapKey( tab, o ) );
tab.remove( o );
}
o.safeRelease();
}
@@ -216,7 +183,7 @@ public abstract class ROT {
" table size prior to addition:" + tab.size() );
}
if ( tab != null ) {
tab.put( getMapKey( tab, o ), getMapValue( tab, o ) );
tab.put( o, null );
}
}