poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 56420] New: Sumif throws NullPointerException
Date Thu, 17 Apr 2014 02:58:33 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=56420

            Bug ID: 56420
           Summary: Sumif throws NullPointerException
           Product: POI
           Version: 3.10
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: POI Overall
          Assignee: dev@poi.apache.org
          Reporter: kameda.sbng@gmail.com

When I use SUMIF function in xls file.
If predicate value is cell and cell value is null,
org.apache.poi.ss.formula.functions.Sumif.accumulate method throws
NullPointerException.

This is stack trace:

java.lang.NullPointerException
        at org.apache.poi.ss.formula.functions.Sumif.accumulate(Sumif.java:92)
        at
org.apache.poi.ss.formula.functions.Sumif.sumMatchingCells(Sumif.java:83)
        at org.apache.poi.ss.formula.functions.Sumif.eval(Sumif.java:72)
        at org.apache.poi.ss.formula.functions.Sumif.evaluate(Sumif.java:65)
        at
org.apache.poi.ss.formula.functions.Var2or3ArgFunction.evaluate(Var2or3ArgFunction.java:36)
        at
org.apache.poi.ss.formula.OperationEvaluatorFactory.evaluate(OperationEvaluatorFactory.java:132)
        at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluateFormula(WorkbookEvaluator.java:525)
        at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluateAny(WorkbookEvaluator.java:288)
        at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluate(WorkbookEvaluator.java:230)
        at
org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateFormulaCellValue(HSSFFormulaEvaluator.java:351)
        at
org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateFormulaCell(HSSFFormulaEvaluator.java:213)
        at
org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateAllFormulaCells(HSSFFormulaEvaluator.java:324)
        at
org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateAll(HSSFFormulaEvaluator.java:343)

And this is the code that throws NullPointerException:

(Sumif.java)
 89   private static double accumulate(AreaEval aeRange, I_MatchPredicate mp,
AreaEval aeSum, int relRowIndex,
 90       int relColIndex) {
 91
 92     if (!mp.matches(aeRange.getRelativeValue(relRowIndex, relColIndex))) {
// <------ This line
 93       return 0.0;
 94     }
 95     ValueEval addend = aeSum.getRelativeValue(relRowIndex, relColIndex);
 96     if (addend instanceof NumberEval) {
 97       return ((NumberEval)addend).getNumberValue();
 98     }
 99     // everything else (including string and boolean values) counts as zero
100     return 0.0;
101   }


I guess that mp is null when predicate value is null. But I have not verified
it.
Anyone can fix this bug?


----
Yoshihiro Kameda

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


Mime
View raw message