From: Javen O'Neal Date: Wed, 18 Oct 2017 14:40:56 +0000 (+0000) Subject: cleanup for r1812470: avoid NPEs from string.isEmpty() X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=22e4bc2399165e6273f61e6ce7057b493771f849;p=poi.git cleanup for r1812470: avoid NPEs from string.isEmpty() git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1812532 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java b/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java index 34842a5bd3..d66ef83397 100644 --- a/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java +++ b/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java @@ -478,7 +478,7 @@ public class ToHtml { CellFormat cf = CellFormat.getInstance( style.getDataFormatString()); CellFormatResult result = cf.apply(cell); - content = result.text; + content = result.text; //never null if (content.isEmpty()) { content = " "; } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java index 8ceec105e2..f19f1ac562 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java @@ -169,8 +169,8 @@ public abstract class BaseTestCellComment { assertNotNull("Cells in the second column have comments", sheet.getCellComment(new CellAddress(rownum, 1))); assertEquals("Yegor Kozlov", comment.getAuthor()); - assertFalse("cells in the second column have not empyy notes", - comment.getString().getString().isEmpty()); + assertTrue("cells in the second column should have non-empty notes", + !comment.getString().getString().isEmpty()); assertEquals(rownum, comment.getRow()); assertEquals(cell.getColumnIndex(), comment.getColumn()); }