bug 59222: fix NPE thrown by (S)XSSFSheet.getCellComments(). Reported by Vasily Kopytov.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1736347 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1128818a70
commit
784b07e424
@ -778,6 +778,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
||||
*/
|
||||
@Override
|
||||
public Map<CellAddress, XSSFComment> getCellComments() {
|
||||
if (sheetComments == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return sheetComments.getCellComments();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user