You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by sh...@apache.org on 2019/02/04 10:58:05 UTC

[fineract] branch develop updated: Fixing Apache POI issue - Formula Cell evaluation nullpointer exception

This is an automated email from the ASF dual-hosted git repository.

shruthirajaram pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new 650e1dd  Fixing Apache POI issue - Formula Cell evaluation nullpointer exception
     new 97ed254  Merge pull request #457 from wkk91193/fixing-formular-cell-evaluation-npe
650e1dd is described below

commit 650e1ddd8b5dfaf4c6eb2a44512390e9011d4be4
Author: unknown <wk...@yahoo.com>
AuthorDate: Fri Jun 15 23:13:38 2018 +0530

    Fixing Apache POI issue - Formula Cell evaluation nullpointer exception
---
 .../importhandler/ImportHandlerUtils.java          | 40 ++++++++++++++++++----
 1 file changed, 33 insertions(+), 7 deletions(-)

diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java
index c396f98..1e794ed 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java
@@ -63,8 +63,13 @@ public class ImportHandlerUtils {
         FormulaEvaluator eval = row.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
         if(c.getCellType() == Cell.CELL_TYPE_FORMULA) {
             if(eval!=null) {
-                CellValue val = eval.evaluate(c);
-                return ((Double) val.getNumberValue()).longValue();
+                CellValue val = null;
+                try {
+                    val = eval.evaluate(c);
+                } catch (NullPointerException npe) {
+                    return null;
+                }
+                return ((Double)val.getNumberValue()).longValue();
             }
         }
         else if (c.getCellType()==Cell.CELL_TYPE_NUMERIC){
@@ -85,7 +90,13 @@ public class ImportHandlerUtils {
         FormulaEvaluator eval = row.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
         if(c.getCellType() == Cell.CELL_TYPE_FORMULA) {
             if (eval!=null) {
-                CellValue val = eval.evaluate(c);
+                CellValue val = null;
+                try {
+                    val = eval.evaluate(c);
+                } catch(NullPointerException npe) {
+                    return null;
+                }
+
                 String res = trimEmptyDecimalPortion(val.getStringValue());
                 if (res!=null) {
                     if (!res.equals("")) {
@@ -136,7 +147,12 @@ public class ImportHandlerUtils {
             FormulaEvaluator eval = row.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
             if(c.getCellType() == Cell.CELL_TYPE_FORMULA) {
                 if(eval!=null) {
-                    CellValue val = eval.evaluate(c);
+                    CellValue val = null;
+                    try {
+                        val = eval.evaluate(c);
+                    } catch (NullPointerException npe) {
+                        return false;
+                    }
                     return val.getBooleanValue();
                 }
                 return false;
@@ -158,8 +174,13 @@ public class ImportHandlerUtils {
             FormulaEvaluator eval = row.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
             if(c.getCellType() == Cell.CELL_TYPE_FORMULA) {
                 if(eval!=null) {
-                   CellValue val = eval.evaluate(c);
-                    return ((Double) val.getNumberValue()).intValue();
+                    CellValue val = null;
+                    try {
+                        val = eval.evaluate(c);
+                    } catch (NullPointerException npe) {
+                        return null;
+                    }
+                    return ((Double)val.getNumberValue()).intValue();
                 }
                 return null;
             }else if (c.getCellType()==Cell.CELL_TYPE_NUMERIC) {
@@ -176,7 +197,12 @@ public class ImportHandlerUtils {
         FormulaEvaluator eval = row.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
         if(c.getCellType() == Cell.CELL_TYPE_FORMULA) {
                 if (eval!=null) {
-                    CellValue val = eval.evaluate(c);
+                    CellValue val = null;
+                    try {
+                        val = eval.evaluate(c);
+                    } catch (NullPointerException npe) {
+                        return 0.0;
+                    }
                     return val.getNumberValue();
                 }else {
                     return 0.0;