You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/09/11 02:02:56 UTC

svn commit: r1760213 - /poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java

Author: onealj
Date: Sun Sep 11 02:02:56 2016
New Revision: 1760213

URL: http://svn.apache.org/viewvc?rev=1760213&view=rev
Log:
bug 59958: Add cells on the fly to the evaluation sheet cache on cache miss; patch from Tomasz Stanczak

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java?rev=1760213&r1=1760212&r2=1760213&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java Sun Sep 11 02:02:56 2016
@@ -67,7 +67,28 @@ final class XSSFEvaluationSheet implemen
             }
         }
         
-        return _cellCache.get(new CellKey(rowIndex, columnIndex));
+        final CellKey key = new CellKey(rowIndex, columnIndex);
+        EvaluationCell evalcell = _cellCache.get(key);
+        
+        // If cache is stale, update cache with this one cell
+        // This is a compromise between rebuilding the entire cache
+        // (which would quickly defeat the benefit of the cache)
+        // and not caching at all.
+        // See bug 59958: Add cells on the fly to the evaluation sheet cache on cache miss
+        if (evalcell == null) {
+            XSSFRow row = _xs.getRow(rowIndex);
+            if (row == null) {
+                return null;
+            }
+            XSSFCell cell = row.getCell(columnIndex);
+            if (cell == null) {
+                return null;
+            }
+            evalcell = new XSSFEvaluationCell(cell, this);
+            _cellCache.put(key, evalcell);
+        }
+        
+        return evalcell;
     }
     
     private static class CellKey {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org