From 537ddf53b9607c23208e36536d4efcc1c8b34903 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 20 Nov 2021 16:50:15 +0000 Subject: [PATCH] fix broken test git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895211 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/xssf/usermodel/XSSFSheet.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 66fcbe6499..aa388b377e 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -3051,18 +3051,20 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { // also remove any comments associated with this row if (sheetComments != null) { + ArrayList refsToRemove = new ArrayList<>(); Iterator commentAddressIterator = sheetComments.getCellAddresses(); while (commentAddressIterator.hasNext()) { CellAddress ref = commentAddressIterator.next(); - // is this comment part of the current row? if(rowsToRemoveSet.contains(ref.getRow())) { - sheetComments.removeComment(ref); - if (vml != null) { - vml.removeCommentShape(ref.getRow(), ref.getColumn()); - } + refsToRemove.add(ref); + } + } + for (CellAddress ref : refsToRemove) { + sheetComments.removeComment(ref); + if (vml != null) { + vml.removeCommentShape(ref.getRow(), ref.getColumn()); } - } } @@ -3106,7 +3108,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { XSSFRow row = (XSSFRow)it.next(); int rownum = row.getRowNum(); - if(sheetComments != null){ + if(sheetComments != null) { // calculate the new rownum int newrownum = shiftedRowNum(startRow, endRow, n, rownum);