From: Yegor Kozlov Date: Sat, 22 May 2010 16:24:22 +0000 (+0000) Subject: avoid NPE when finding cell comments, Bugzilla 48846 X-Git-Tag: REL_3_7_BETA1~71 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e79cc21802e5204a508d177aa3ff5d1331101b46;p=poi.git avoid NPE when finding cell comments, Bugzilla 48846 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@947315 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index ea298f9298..bb66430073 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 48846 - Avoid NPE when finding cell comments 49325 - Ensure that CTPhoneticPr is included in poi-ooxml jar 49191 - Fixed tests failing in non-english locales 48432 - Support for XSSF themes diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java index ac7ab6f911..a490d44dfd 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java @@ -1079,12 +1079,16 @@ public class HSSFCell implements Cell { if (note.getRow() == row && note.getColumn() == column) { if(i < noteTxo.size()) { TextObjectRecord txo = noteTxo.get(note.getShapeId()); - comment = new HSSFComment(note, txo); - comment.setRow(note.getRow()); - comment.setColumn((short) note.getColumn()); - comment.setAuthor(note.getAuthor()); - comment.setVisible(note.getFlags() == NoteRecord.NOTE_VISIBLE); - comment.setString(txo.getStr()); + if(txo != null){ + comment = new HSSFComment(note, txo); + comment.setRow(note.getRow()); + comment.setColumn(note.getColumn()); + comment.setAuthor(note.getAuthor()); + comment.setVisible(note.getFlags() == NoteRecord.NOTE_VISIBLE); + comment.setString(txo.getStr()); + } else{ + log.log(POILogger.WARN, "Failed to match NoteRecord and TextObjectRecord, row: " + row + ", column: " + column); + } } else { log.log(POILogger.WARN, "Failed to match NoteRecord and TextObjectRecord, row: " + row + ", column: " + column); } diff --git a/test-data/spreadsheet/49325.xlsx b/test-data/spreadsheet/49325.xlsx new file mode 100755 index 0000000000..adcba90b77 Binary files /dev/null and b/test-data/spreadsheet/49325.xlsx differ