bug 59958: Add cells on the fly to the evaluation sheet cache on cache miss; patch from Tomasz Stanczak

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1760213 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-09-11 02:02:56 +00:00
parent d9cfcbdd18
commit 6146860a5e

View File

@ -67,7 +67,28 @@ final class XSSFEvaluationSheet implements EvaluationSheet {
} }
} }
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 { private static class CellKey {