pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1823663 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form: PDChoice.java PDSignatureField.java PDVariableText.java
Date Fri, 09 Feb 2018 14:59:32 GMT
Author: msahyoun
Date: Fri Feb  9 14:59:32 2018
New Revision: 1823663

URL: http://svn.apache.org/viewvc?rev=1823663&view=rev
Log:
PDFBOX-4071: avoid ClassCastException, no need to test for null with instanceof

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java?rev=1823663&r1=1823662&r2=1823663&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.java
Fri Feb  9 14:59:32 2018
@@ -224,7 +224,7 @@ public abstract class PDChoice extends P
     public List<Integer> getSelectedOptionsIndex()
     {
         COSBase value = getCOSObject().getDictionaryObject(COSName.I);
-        if (value != null)
+        if (value instanceof COSArray)
         {
             return COSArrayList.convertIntegerCOSArrayToList((COSArray) value);
         }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java?rev=1823663&r1=1823662&r2=1823663&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureField.java
Fri Feb  9 14:59:32 2018
@@ -162,11 +162,11 @@ public class PDSignatureField extends PD
     public PDSignature getValue()
     {
         COSBase value = getCOSObject().getDictionaryObject(COSName.V);
-        if (value == null)
+        if (value instanceof COSDictionary)
         {
-            return null;
+            return new PDSignature((COSDictionary)value);
         }
-        return new PDSignature((COSDictionary)value);
+        return null;
     }
 
     /**

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java?rev=1823663&r1=1823662&r2=1823663&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java
Fri Feb  9 14:59:32 2018
@@ -224,11 +224,7 @@ public abstract class PDVariableText ext
      */
     protected final String getStringOrStream(COSBase base)
     {
-        if (base == null)
-        {
-            return "";
-        }
-        else if (base instanceof COSString)
+        if (base instanceof COSString)
         {
             return ((COSString)base).getString();
         }
@@ -236,9 +232,6 @@ public abstract class PDVariableText ext
         {
             return ((COSStream)base).toTextString();
         }
-        else
-        {
-            return "";
-        }
+        return "";
     }
 }



Mime
View raw message