CaseInsensitiveMap is not thread-safe

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894738 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2021-11-04 18:30:31 +00:00
parent 584c8c059b
commit e40b4e1ec9
2 changed files with 5 additions and 6 deletions

View File

@ -19,8 +19,8 @@ package org.apache.poi.xssf.usermodel;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentSkipListMap;
import org.apache.commons.collections4.map.CaseInsensitiveMap;
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.EvaluationName;
import org.apache.poi.ss.formula.EvaluationWorkbook;
@ -364,7 +364,7 @@ public abstract class BaseXSSFEvaluationWorkbook implements FormulaRenderingWork
if ( _tableCache != null ) {
return _tableCache;
}
_tableCache = new CaseInsensitiveMap<>();
_tableCache = new ConcurrentSkipListMap<>(String.CASE_INSENSITIVE_ORDER);
for (Sheet sheet : _uBook) {
for (XSSFTable tbl : ((XSSFSheet)sheet).getTables()) {

View File

@ -26,8 +26,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentSkipListMap;
import org.apache.commons.collections4.map.CaseInsensitiveMap;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.ss.SpreadsheetVersion;
@ -59,7 +59,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
private CTTable ctTable;
private transient List<XSSFXmlColumnPr> xmlColumnPrs;
private transient List<XSSFTableColumn> tableColumns;
private transient CaseInsensitiveMap<String, Integer> columnMap;
private transient ConcurrentSkipListMap<String, Integer> columnMap;
private transient CellReference startCellReference;
private transient CellReference endCellReference;
private transient String commonXPath;
@ -831,8 +831,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
public int findColumnIndex(String columnHeader) {
if (columnHeader == null) return -1;
if (columnMap == null) {
final int count = getColumnCount();
columnMap = new CaseInsensitiveMap<>(count * 3 / 2);
columnMap = new ConcurrentSkipListMap<>(String.CASE_INSENSITIVE_ORDER);
int i = 0;
for (XSSFTableColumn column : getColumns()) {