[jboss-svn-commits] JBL Code SVN: r11817 - labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu May 10 14:44:29 EDT 2007


Author: tirelli
Date: 2007-05-10 14:44:29 -0400 (Thu, 10 May 2007)
New Revision: 11817

Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
Log:
JBRULES-811: fixing one more object leak

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java	2007-05-10 17:23:16 UTC (rev 11816)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java	2007-05-10 18:44:29 UTC (rev 11817)
@@ -928,15 +928,19 @@
             doRetract( handle,
                        propagationContext );
 
-            // set anyway, so that it updates the hashCodes
-            handle.setObject( object );
+            if(( originalObject != object ) || ( this.ruleBase.getConfiguration().getAssertBehaviour() != AssertBehaviour.IDENTITY )) {
+                // as assertMap may be using an "identity" equality comparator,
+                // we need to remove the handle from the map, before replacing the object
+                // and then re-add the handle. Otherwise we may end up with a leak.
+                this.assertMap.remove( handle );
+                // set anyway, so that it updates the hashCodes
+                handle.setObject( object );
+                this.assertMap.put( handle, 
+                                    handle, 
+                                    false );
+            }  
 
             if ( this.maintainTms ) {
-                // We only need to put objects, if its a new object
-                if ( originalObject != object ) {
-                    this.assertMap.put( handle,
-                                        handle );
-                }
 
                 // the hashCode and equality has changed, so we must update the EqualityKey
                 EqualityKey key = handle.getEqualityKey();




More information about the jboss-svn-commits mailing list