]> source.dussan.org Git - poi.git/commitdiff
Fix bug #51273 - Hash codes can be negative when working on our own low memory hash...
authorNick Burch <nick@apache.org>
Fri, 27 May 2011 11:45:50 +0000 (11:45 +0000)
committerNick Burch <nick@apache.org>
Fri, 27 May 2011 11:45:50 +0000 (11:45 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1128268 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/java/org/apache/poi/ss/formula/FormulaCellCacheEntrySet.java

index c0790c9f337b306c4b96b23b64a361f4663e1ef3..5da84b934b72ab90522b0d70d5a5d23263fbb54f 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta3" date="2011-??-??">
+           <action dev="poi-developers" type="fix">51273 - Formula Value Cache fix for repeated evaluations</action>
            <action dev="poi-developers" type="add">51171 - Improved performance of SharedValueManager </action>
            <action dev="poi-developers" type="fix">51236 - XSSF set colour support for black/white to match getter</action>
            <action dev="poi-developers" type="add">51196 - Initial support for Spreadsheet Chart API</action>
index d8e573150ecc39080f36a877e6e82aeca7ac56df..9a40cbc95e1ca68d0dcaf3a4eafa9aead5334a56 100644 (file)
@@ -76,8 +76,7 @@ final class FormulaCellCacheEntrySet {
 
 
        private static boolean addInternal(CellCacheEntry[] arr, CellCacheEntry cce) {
-
-               int startIx = cce.hashCode() % arr.length;
+               int startIx = Math.abs(cce.hashCode() % arr.length);
 
                for(int i=startIx; i<arr.length; i++) {
                        CellCacheEntry item = arr[i];
@@ -130,7 +129,7 @@ final class FormulaCellCacheEntrySet {
                // else - usual case
                // delete single element (without re-hashing)
 
-               int startIx = cce.hashCode() % arr.length;
+               int startIx = Math.abs(cce.hashCode() % arr.length);
 
                // note - can't exit loops upon finding null because of potential previous deletes
                for(int i=startIx; i<arr.length; i++) {