Uploaded image for project: 'Keikai'
  1. Keikai
  2. KEIKAI-457

evaluating IF() produces a NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • 5.8.0
    • 5.7.0
    • None
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      1. load the attached xlsx
      Or
      Test case io.keikai.model.FormulaEvalTest.keikai457()

      Current Result

      2021-03-29 14:35:26 [ERROR] FormulaEngineImpl:491 - null when eval IF(B1>10, 1,0)
      java.lang.NullPointerException
      at org.zkoss.poi.ss.formula.eval.RelationalOperationEval.evaluate(RelationalOperationEval.java:72)
      at org.zkoss.poi.ss.formula.functions.Fixed2ArgFunction.evaluate(Fixed2ArgFunction.java:48)
      at org.zkoss.poi.ss.formula.OperationEvaluatorFactory.evaluate(OperationEvaluatorFactory.java:134)
      at org.zkoss.poi.ss.formula.WorkbookEvaluator.evaluateFormula(WorkbookEvaluator.java:625)
      at org.zkoss.poi.ss.formula.WorkbookEvaluator.evaluateAny(WorkbookEvaluator.java:355)
      at org.zkoss.poi.ss.formula.WorkbookEvaluator.evaluate(WorkbookEvaluator.java:294)
      at io.keikai.model.impl.sys.formula.FormulaEngineImpl.evaluateFormula(FormulaEngineImpl.java:587)
      at io.keikai.model.impl.sys.formula.FormulaEngineImpl.evaluate(FormulaEngineImpl.java:467)
      at io.keikai.model.impl.CellImpl.evalFormula(CellImpl.java:201)
      at io.keikai.model.impl.CellImpl.getFormulaResultType(CellImpl.java:218)
      at io.keikai.ui.SpreadsheetCtrlImpl.getCellAttr(SpreadsheetCtrlImpl.java:495)
      at io.keikai.ui.SpreadsheetCtrlImpl.getRangeAttrs(SpreadsheetCtrlImpl.java:382)
      at io.keikai.ui.Spreadsheet.createActiveRange(Spreadsheet.java:1970)
      at io.keikai.ui.Spreadsheet.renderProperties(Spreadsheet.java:1923)

      Expected Result

      no error

      Debug Information

      1. in RelationalOperationEval, context becomes null after calculating vA with OperandResolver.getSingleValue()

      			vA = context.isEvalNameFormula()
      					? OperandResolver.getSingleValueInNameFormula(arg0, srcRowIndex, srcColumnIndex)
      					: OperandResolver.getSingleValue(arg0, srcRowIndex, srcColumnIndex);
      			vB = context.isEvalNameFormula()
      					? OperandResolver.getSingleValueInNameFormula(arg1, srcRowIndex, srcColumnIndex)
      					: OperandResolver.getSingleValue(arg1, srcRowIndex, srcColumnIndex);
      

      RelationalOperationEval is used as singleton, so while evaluating one RelationalOperationEval and evaluating another RelationalOperationEval will turn context into null. Should not put context in a singleton

      Workaround


            DevChu DevChu
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: