pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1822398 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
Date Sat, 27 Jan 2018 12:07:57 GMT
Author: tilman
Date: Sat Jan 27 12:07:57 2018
New Revision: 1822398

URL: http://svn.apache.org/viewvc?rev=1822398&view=rev
Log:
PDFBOX-4084: avoid ClassCastException

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java?rev=1822398&r1=1822397&r2=1822398&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java Sat Jan
27 12:07:57 2018
@@ -657,14 +657,10 @@ public class PDPage implements COSObject
      */
     public List<PDAnnotation> getAnnotations() throws IOException
     {
-        COSArrayList<PDAnnotation> retval;
-        COSArray annots = (COSArray) page.getDictionaryObject(COSName.ANNOTS);
-        if (annots == null)
-        {
-            return new COSArrayList<PDAnnotation>(page, COSName.ANNOTS);
-        }
-        else
+        COSBase base = page.getDictionaryObject(COSName.ANNOTS);
+        if (base instanceof COSArray)
         {
+            COSArray annots = (COSArray) base;
             List<PDAnnotation> actuals = new ArrayList<PDAnnotation>();
             for (int i = 0; i < annots.size(); i++)
             {
@@ -675,9 +671,9 @@ public class PDPage implements COSObject
                 }
                 actuals.add(PDAnnotation.createAnnotation(item));
             }
-            retval = new COSArrayList<PDAnnotation>(actuals, annots);
+            return new COSArrayList<PDAnnotation>(actuals, annots);
         }
-        return retval;
+        return new COSArrayList<PDAnnotation>(page, COSName.ANNOTS);
     }
 
     /**



Mime
View raw message