aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java5
-rw-r--r--poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java34
-rw-r--r--test-data/spreadsheet/bug66319.xlsbin0 -> 387072 bytes
3 files changed, 35 insertions, 4 deletions
diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
index c8e3c9bad3..f50e18edb9 100644
--- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
+++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
@@ -2527,10 +2527,7 @@ public final class HSSFSheet implements Sheet {
protected HSSFComment findCellComment(int row, int column) {
HSSFPatriarch patriarch = getDrawingPatriarch();
- if (null == patriarch) {
- patriarch = createDrawingPatriarch();
- }
- return lookForComment(patriarch, row, column);
+ return patriarch == null ? null : lookForComment(patriarch, row, column);
}
private HSSFComment lookForComment(HSSFShapeContainer container, int row, int column) {
diff --git a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java
index c9cc7c748a..b29c4bc3ee 100644
--- a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java
+++ b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java
@@ -2609,4 +2609,38 @@ final class TestBugs extends BaseTestBugzillaIssues {
assertNotNull(wb);
}
}
+
+ @Test
+ void test66319() throws IOException {
+ try (
+ HSSFWorkbook workbook = openSampleWorkbook("bug66319.xls");
+ UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()
+ ) {
+ for (Sheet sheet : workbook) {
+ for (Row row : sheet) {
+ for (Cell cell : row) {
+ cell.getCellComment();
+ }
+ }
+ }
+ workbook.write(bos);
+ }
+ }
+
+ @Test
+ void test66319WithRemove() throws IOException {
+ try (
+ HSSFWorkbook workbook = openSampleWorkbook("bug66319.xls");
+ UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()
+ ) {
+ for (Sheet sheet : workbook) {
+ for (Row row : sheet) {
+ for (Cell cell : row) {
+ cell.removeCellComment();
+ }
+ }
+ }
+ workbook.write(bos);
+ }
+ }
}
diff --git a/test-data/spreadsheet/bug66319.xls b/test-data/spreadsheet/bug66319.xls
new file mode 100644
index 0000000000..163ce16e7d
--- /dev/null
+++ b/test-data/spreadsheet/bug66319.xls
Binary files differ