diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 13f6b09165..5b4013b8aa 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -110,7 +110,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { protected CTSheet sheet; protected CTWorksheet worksheet; - private SortedMap _rows; + private final SortedMap _rows = new TreeMap(); private List hyperlinks; private ColumnHelper columnHelper; private CommentsTable sheetComments; @@ -216,7 +216,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { } private void initRows(CTWorksheet worksheetParam) { - _rows = new TreeMap(); + _rows.clear(); tables = new TreeMap(); sharedFormulas = new HashMap(); arrayFormulas = new ArrayList(); @@ -3024,13 +3024,14 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { rowShifter.updateHyperlinks(shifter); //rebuild the _rows map - SortedMap map = new TreeMap(); + Map map = new HashMap(); for(XSSFRow r : _rows.values()) { // Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory final Integer rownumI = new Integer(r.getRowNum()); // NOSONAR map.put(rownumI, r); } - _rows = map; + _rows.clear(); + _rows.putAll(map); } private int shiftedRowNum(int startRow, int endRow, int n, int rownum) {