pjfanning opened a new pull request, #1307:
URL: https://github.com/apache/poi/pull/1307
## Summary
Adds `BaseTestFormulaEvaluatorCacheNotification` with HSSF and XSSF
subclasses. One fixture workbook, built in code, is shared by 17 tests:
```
A B C D
1 Qty Item Cost Price
2 10 Widget 5
=VLOOKUP(B2,Prices!$A$2:$B$4,2,FALSE)
3 20 Gadget 7
=VLOOKUP(B3,Prices!$A$2:$B$4,2,FALSE)
4 30 Gizmo 9
=VLOOKUP(B4,Prices!$A$2:$B$4,2,FALSE)
5
6 =SUM(A2:A4) =SUM(C2:C4)
=SUMPRODUCT(A2:A4,D2:D4)
7 =A6*2 =A7+C6 =COUNTIF(A2:A4,">15")
8 =B7/3 =IF(A8>40,"big","small") =CONCATENATE(B2,"-",B8)
9 =A8+A7 =Total+C7 (Total = Data!$A$6)
```
plus a `Prices` sheet. The tests evaluate everything, then change plain
values and formulas (including ones other formulas depend on), notify the
evaluator via `notifyUpdateCell` / `notifySetFormula` / `notifyDeleteCell`, and
assert the re-evaluated results: propagation through the chain, cross-sheet
updates, lookup key changes and `#N/A` recovery, `IF` branch flips,
formula→value and value→formula conversions, cell deletion, blank→value→blank,
batched changes, and `clearAllCachedResultValues` as the alternative. The
header rows, spare row 5 and ranges over the data block are there so row
insertion/deletion tests can be added against the same fixture later.
## Bug found and fixed
`XSSFFormulaEvaluator.notifyDeleteCell` wraps the cell in a throw-away
`XSSFEvaluationSheet`, so the *cached* `XSSFEvaluationSheet` (in
`XSSFEvaluationWorkbook._sheetCache`) kept its `EvaluationCell` wrapper for the
removed cell. The next evaluation of a range containing that cell read a
detached `CTCell` and threw `XmlValueDisconnectedException`. HSSF is unaffected
because `HSSFEvaluationSheet` does not cache wrappers.
- `EvaluationSheet`: new `default void notifyDeleteCell(int rowIndex, int
columnIndex)` (no-op)
- `WorkbookEvaluator.notifyDeleteCell`: after clearing the result cache,
calls it on `_workbook.getSheet(sheetIndex)` — the live sheet instance
- `XSSFEvaluationSheet`: overrides it to evict the `CellKey` from
`_cellCache`
## Test plan
- [x] `TestHSSFFormulaEvaluatorCacheNotification`,
`TestXSSFFormulaEvaluatorCacheNotification` (17 each)
- [x] `org.apache.poi.ss.formula.*`, `TestHSSFFormulaEvaluator`,
`TestXSSFFormulaEvaluation`, `TestSXSSFFormulaEvaluation`,
`TestXSSFEvaluationSheet`, `TestXSSFSheetShiftRows`
- [ ] CI
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]