pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1861856 - /pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java
Date Sat, 22 Jun 2019 12:15:17 GMT
Author: tilman
Date: Sat Jun 22 12:15:17 2019
New Revision: 1861856

URL: http://svn.apache.org/viewvc?rev=1861856&view=rev
Log:
PDFBOX-4071: Simplify code: PDXObject.createXObject() never returns null for non-null argument.

Modified:
    pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java

Modified: pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java?rev=1861856&r1=1861855&r2=1861856&view=diff
==============================================================================
--- pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java
(original)
+++ pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java
Sat Jun 22 12:15:17 2019
@@ -208,32 +208,26 @@ public class ResourcesValidationProcess
         COSDocument cosDocument = context.getDocument().getDocument();
         COSDictionary mapOfXObj = COSUtils.getAsDictionary(resources.getCOSObject().getItem(COSName.XOBJECT),
                 cosDocument);
-        if (mapOfXObj != null)
+        if (mapOfXObj == null)
         {
-            for (Entry<COSName, COSBase> entry : mapOfXObj.entrySet())
+            return;
+        }
+        for (Entry<COSName, COSBase> entry : mapOfXObj.entrySet())
+        {
+            COSBase xobj = entry.getValue();
+            if (xobj != null && COSUtils.isStream(xobj, cosDocument))
             {
-                COSBase xobj = entry.getValue();
-                if (xobj != null && COSUtils.isStream(xobj, cosDocument))
+                try
+                {
+                    COSStream stream = COSUtils.getAsStream(xobj, cosDocument);
+                    PDXObject pdXObject = PDXObject.createXObject(stream, resources);
+                    ContextHelper.validateElement(context, pdXObject, GRAPHIC_PROCESS);
+                }
+                catch (IOException e)
                 {
-                    try
-                    {
-                        COSStream stream = COSUtils.getAsStream(xobj, cosDocument);
-                        PDXObject pdXObject = PDXObject.createXObject(stream, resources);
-                        if (pdXObject != null)
-                        {
-                            ContextHelper.validateElement(context, pdXObject, GRAPHIC_PROCESS);
-                        }
-                        else
-                        {
-                            ContextHelper.validateElement(context, stream, GRAPHIC_PROCESS);
-                        }
-                    }
-                    catch (IOException e)
-                    {
-                        context.addValidationError(new ValidationError(ERROR_GRAPHIC_MAIN,
-                                e.getMessage() + " for entry '"
-                                + entry.getKey().getName() + "'", e));
-                    }
+                    context.addValidationError(new ValidationError(ERROR_GRAPHIC_MAIN,
+                            e.getMessage() + " for entry '"
+                            + entry.getKey().getName() + "'", e));
                 }
             }
         }



Mime
View raw message