poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1736347 - in /poi/trunk/src: ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
Date Wed, 23 Mar 2016 16:42:05 GMT
Author: onealj
Date: Wed Mar 23 16:42:04 2016
New Revision: 1736347

URL: http://svn.apache.org/viewvc?rev=1736347&view=rev
Log:
bug 59222: fix NPE thrown by (S)XSSFSheet.getCellComments(). Reported by Vasily Kopytov.

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1736347&r1=1736346&r2=1736347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Wed Mar 23 16:42:04
2016
@@ -778,6 +778,9 @@ public class XSSFSheet extends POIXMLDoc
      */
     @Override
     public Map<CellAddress, XSSFComment> getCellComments() {
+        if (sheetComments == null) {
+            return Collections.emptyMap();
+        }
         return sheetComments.getCellComments();
     }
 

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java?rev=1736347&r1=1736346&r2=1736347&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java Wed Mar 23 16:42:04
2016
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeTrue;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -1119,6 +1120,10 @@ public abstract class BaseTestSheet {
     public void getCellComments() throws IOException {
         Workbook workbook = _testDataProvider.createWorkbook();
         Sheet sheet = workbook.createSheet("TEST");
+
+        // a sheet with no cell comments should return an empty map (not null or raise NPE).
+        assertEquals(Collections.emptyMap(), sheet.getCellComments());
+
         Drawing dg = sheet.createDrawingPatriarch();
         ClientAnchor anchor = workbook.getCreationHelper().createClientAnchor();
         



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message