]> source.dussan.org Git - poi.git/commitdiff
try to handle case where checksum is null
authorPJ Fanning <fanningpj@apache.org>
Thu, 10 Dec 2020 12:24:19 +0000 (12:24 +0000)
committerPJ Fanning <fanningpj@apache.org>
Thu, 10 Dec 2020 12:24:19 +0000 (12:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1884278 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java

index 8158b81e80f78c4877299e891913cc2f2dba1671..548c61466157ed962d52e6c5ad72ba46f656d303 100644 (file)
@@ -124,7 +124,7 @@ public class XWPFPictureData extends POIXMLDocumentPart {
     /**
      * Return an integer constant that specifies type of this picture
      *
-     * @return an integer constant that specifies type of this picture
+     * @return an integer constant that specifies type of this picture, returns 0 if an unknown type
      * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_EMF
      * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_WMF
      * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_PICT
@@ -217,15 +217,22 @@ public class XWPFPictureData extends POIXMLDocumentPart {
         Long foreignChecksum = picData.getChecksum();
         Long localChecksum = getChecksum();
 
-        if (!(localChecksum.equals(foreignChecksum))) {
-            return false;
+        if (localChecksum == null) {
+            if (foreignChecksum != null) {
+                return false;
+            }
+        } else {
+            if (!(localChecksum.equals(foreignChecksum))) {
+                return false;
+            }
         }
         return Arrays.equals(this.getData(), picData.getData());
     }
 
     @Override
     public int hashCode() {
-        return getChecksum().hashCode();
+        Long checksum = getChecksum();
+        return checksum == null ? super.hashCode() : checksum.hashCode();
     }
 
     /**