Author: msahyoun
Date: Tue Mar  6 10:43:58 2018
New Revision: 1825973

URL: http://svn.apache.org/viewvc?rev=1825973&view=rev
Log:
PDFBOX-4122: add null check to please Sonar; added TODO to generally handle 
null being passed to public methods

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1825973&r1=1825972&r2=1825973&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java 
(original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java 
Tue Mar  6 10:43:58 2018
@@ -518,7 +518,12 @@ public class COSWriter implements ICOSVi
             getStandardOutput().write(SPACE);
             getStandardOutput().write(OBJ);
             getStandardOutput().writeEOL();
-            obj.accept( this );
+            // null test added to please Sonar
+            // TODO: shouldn't all public methods be guarded against passing 
null. Passing null to most methods will
+            // fail with an NPE
+            if (obj != null) {
+                obj.accept( this );
+            }
             getStandardOutput().writeEOL();
             getStandardOutput().write(ENDOBJ);
             getStandardOutput().writeEOL();


Reply via email to