You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2020/12/08 17:09:36 UTC

svn commit: r1884210 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/HSSFCell.java ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java

Author: fanningpj
Date: Tue Dec  8 17:09:36 2020
New Revision: 1884210

URL: http://svn.apache.org/viewvc?rev=1884210&view=rev
Log:
[bug-64964] HSSFCell.convertCellValueToBoolean shall throw more specific exception

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java?rev=1884210&r1=1884209&r2=1884210&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java Tue Dec  8 17:09:36 2020
@@ -831,6 +831,7 @@ public class HSSFCell extends CellBase {
      * setCellValue(boolean) straight afterwards.  This method only exists to give
      * the cell a somewhat reasonable value until the setCellValue() call (if at all).
      * TODO - perhaps a method like setCellTypeAndValue(int, Object) should be introduced to avoid this
+     * @throws IllegalStateException if cell type cannot be converted to boolean
      */
     private boolean convertCellValueToBoolean() {
 
@@ -855,8 +856,9 @@ public class HSSFCell extends CellBase {
             case BLANK:
                 return false;
         }
-        throw new RuntimeException("Unexpected cell type (" + _cellType + ")");
+        throw new IllegalStateException("Unexpected cell type (" + _cellType + ")");
     }
+
     private String convertCellValueToString() {
 
         switch (_cellType) {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java?rev=1884210&r1=1884209&r2=1884210&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java Tue Dec  8 17:09:36 2020
@@ -915,11 +915,12 @@ public class SXSSFCell extends CellBase
             }
         }
     }
+
 //COPIED FROM https://svn.apache.org/repos/asf/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java since the functions are declared private there
     /**
      * Used to help format error messages
      */
-    private static RuntimeException typeMismatch(CellType expectedTypeCode, CellType actualTypeCode, boolean isFormulaCell) {
+    private static IllegalStateException typeMismatch(CellType expectedTypeCode, CellType actualTypeCode, boolean isFormulaCell) {
         String msg = "Cannot get a " + expectedTypeCode + " value from a " + actualTypeCode
                 + " " + (isFormulaCell ? "formula " : "") + "cell";
         return new IllegalStateException(msg);
@@ -944,7 +945,8 @@ public class SXSSFCell extends CellBase
             case ERROR:
             case BLANK:
                 return false;
-            default: throw new RuntimeException("Unexpected cell type (" + cellType + ")");
+            default:
+                throw new IllegalStateException("Unexpected cell type (" + cellType + ")");
         }
 
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java?rev=1884210&r1=1884209&r2=1884210&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java Tue Dec  8 17:09:36 2020
@@ -1143,6 +1143,8 @@ public final class XSSFCell extends Cell
      * setCellValue(boolean) straight afterwards.  This method only exists to give
      * the cell a somewhat reasonable value until the setCellValue() call (if at all).
      * TODO - perhaps a method like setCellTypeAndValue(CellType, Object) should be introduced to avoid this
+     *
+     * @throws IllegalStateException if cell type cannot be converted to boolean
      */
     private boolean convertCellValueToBoolean() {
         CellType cellType = getCellType();
@@ -1168,7 +1170,7 @@ public final class XSSFCell extends Cell
                 return false;
                 
             default:
-                throw new RuntimeException("Unexpected cell type (" + cellType + ")");
+                throw new IllegalStateException("Unexpected cell type (" + cellType + ")");
         }
     }
 



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