https://bz.apache.org/bugzilla/show_bug.cgi?id=65939

            Bug ID: 65939
           Summary: StackOverflow on notifyUpdateCell
           Product: POI
           Version: 5.2.0-FINAL
          Hardware: PC
            Status: NEW
          Severity: critical
          Priority: P2
         Component: XSSF
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

A java.lang.StackOverflowError occurs on the method
org.apache.poi.ss.formula.CellCacheEntry.recurseClearCachedFormulaResults in
the following condition :
- Create a circular reference on the cell itself (e.g. A1 on cell A1).
- Remove the formula
- Call the notifyUpdateCell method.

Below, a sample code, tested on version 5.2.1, Java 17. :

public static void main(String[] args) {
        try (var workbook = new XSSFWorkbook()) {
                var sheet = workbook.createSheet();
                var row = sheet.createRow(0);
                var cell = row.createCell(0);
                cell.setCellFormula("A1");
                var formulaEvaluator =
workbook.getCreationHelper().createFormulaEvaluator();
                formulaEvaluator.notifyUpdateCell(cell);
                formulaEvaluator.evaluateAll();

               
System.out.println(FormulaError.forInt(cell.getErrorCellValue()));

                cell.setCellFormula(null);
                formulaEvaluator.notifyUpdateCell(cell);

        } catch (IOException e) {
                e.printStackTrace();
        }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to