]> source.dussan.org Git - poi.git/commitdiff
cleanup for r1812476: avoid NPEs from string.isEmpty()
authorJaven O'Neal <onealj@apache.org>
Wed, 18 Oct 2017 14:08:43 +0000 (14:08 +0000)
committerJaven O'Neal <onealj@apache.org>
Wed, 18 Oct 2017 14:08:43 +0000 (14:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1812516 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java
src/java/org/apache/poi/ss/formula/eval/StringEval.java
src/java/org/apache/poi/ss/usermodel/FractionFormat.java
src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RelationshipTransformService.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java

index 9273f53e0e818d4862f4a1b07dde82483d06a02a..6a16e3f9dc53fd1e650732d75b31ae49216489f1 100644 (file)
@@ -374,6 +374,10 @@ public class CryptoFunctions {
      * @return the verifier (actually a short value)
      */
     public static int createXorVerifier1(String password) {
+        if (password == null) {
+            throw new IllegalArgumentException("Password cannot be null");
+        }
+
         byte[] arrByteChars = toAnsiPassword(password);
         
         // SET Verifier TO 0x0000
@@ -412,6 +416,10 @@ public class CryptoFunctions {
      * @see <a href="http://www.aspose.com/blogs/aspose-blogs/vladimir-averkin/archive/2007/08/20/funny-how-the-new-powerful-cryptography-implemented-in-word-2007-turns-it-into-a-perfect-tool-for-document-password-removal.html">Funny: How the new powerful cryptography implemented in Word 2007 turns it into a perfect tool for document password removal.</a>
      */
     public static int createXorVerifier2(String password) {
+        if (password == null) {
+            throw new IllegalArgumentException("Password cannot be null");
+        }
+
         //Array to hold Key Values
         byte[] generatedKey = new byte[4];
 
index 0e35e9dea4f50935ad9b24fe7fdfeb29545542c8..61515e438f795535d31286bbffca9ab3c4607096 100644 (file)
@@ -17,6 +17,8 @@
 
 package org.apache.poi.ss.formula.eval;
 
+//import org.checkerframework.checker.nullness.qual.NonNull;
+
 import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.formula.ptg.StringPtg;
 
@@ -27,6 +29,7 @@ public final class StringEval implements StringValueEval {
 
        public static final StringEval EMPTY_INSTANCE = new StringEval("");
 
+       //@NotNull
        private final String _value;
 
        public StringEval(Ptg ptg) {
index 76834a7ed8d93de27acdba159af03efa62fa11d5..d90d50068b77250376fd40f3db4541f0b1f25fc2 100644 (file)
@@ -150,7 +150,7 @@ public class FractionFormat extends Format {
         }
         
         //if whole part has to go into the numerator
-        if (wholePartFormatString.isEmpty()){
+        if (wholePartFormatString == null || wholePartFormatString.isEmpty()){
             int trueNum = (fract.getDenominator()*(int)wholePart)+fract.getNumerator();
             sb.append(trueNum).append("/").append(fract.getDenominator());
             return sb.toString();
index c4d767fac59626d5be53c019319cf186d7aa608e..0b8037d3ae8c52fc61f46cd2435eacdc176feabf 100644 (file)
@@ -205,7 +205,7 @@ public class RelationshipTransformService extends TransformService {
                 String id = el.getAttribute("Id");
                 if (sourceIds.contains(id)) {
                     String targetMode = el.getAttribute("TargetMode");
-                    if (targetMode.isEmpty()) {
+                    if (targetMode == null || targetMode.isEmpty()) {
                         el.setAttribute("TargetMode", "Internal");
                     }
                     rsList.put(id, el);
index a1a3065a1031291e3fb5a6a114565bbdfb2f2afb..ea533600840cbe234585b9b7862bc31be3b79675 100644 (file)
@@ -845,7 +845,7 @@ public class XSLFTextRun implements TextRun {
                 }
                 // SYMBOL is missing
                 
-                if (font == null || !font.isSetTypeface() || font.getTypeface().isEmpty()) {
+                if (font == null || !font.isSetTypeface() || "".equals(font.getTypeface())) {
                     font = coll.getLatin();
                 }
             }