Author: mrglavas
Date: Tue Aug  9 02:29:14 2011
New Revision: 1155193

URL: http://svn.apache.org/viewvc?rev=1155193&view=rev
Log:
Fixing JIRA Issue #1520: http://issues.apache.org/jira/browse/XERCESJ-1520. 
Corrects several problems with rehash() and removeEntry(), in particular a case 
where we were double counting cleared SoftReferences which could lead to fCount 
becoming negative.

Modified:
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/SoftReferenceSymbolTable.java

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/SoftReferenceSymbolTable.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/SoftReferenceSymbolTable.java?rev=1155193&r1=1155192&r2=1155193&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/SoftReferenceSymbolTable.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/util/SoftReferenceSymbolTable.java
 Tue Aug  9 02:29:14 2011
@@ -225,13 +225,16 @@ public class SoftReferenceSymbolTable ex
                     if (newTable[index] != null) {
                         newTable[index].prev = e;
                     }
+                    e.bucket = index;
                     e.next = newTable[index];
-                    e.prev = null;
                     newTable[index] = e;
                 }
                 else {
-                    fCount--;
+                    e.bucket = -1;
+                    e.next = null;
+                    --fCount;
                 }
+                e.prev = null;
             }
         }
     }
@@ -298,16 +301,19 @@ public class SoftReferenceSymbolTable ex
     } // containsSymbol(char[],int,int):boolean
 
     private void removeEntry(SREntry entry) {
-        if (entry.next != null) {
-            entry.next.prev = entry.prev;
-        }
-        if (entry.prev != null) {
-            entry.prev.next = entry.next;
-        }
-        else {
-            fBuckets[entry.bucket] = entry.next;
+        final int bucket = entry.bucket;
+        if (bucket >= 0) {
+            if (entry.next != null) {
+                entry.next.prev = entry.prev;
+            }
+            if (entry.prev != null) {
+                entry.prev.next = entry.next;
+            }
+            else {
+                fBuckets[bucket] = entry.next;
+            }
+            --fCount;
         }
-        fCount--;
     }
     
     /**
@@ -339,6 +345,7 @@ public class SoftReferenceSymbolTable ex
         /** The previous entry. */
         public SREntry prev;
 
+        /** The bucket this entry is contained in; -1 if it has been removed 
from the table. */
         public int bucket;
         
         //



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@xerces.apache.org
For additional commands, e-mail: commits-h...@xerces.apache.org

Reply via email to