aboutsummaryrefslogtreecommitdiffstats
path: root/poi-excelant/src
diff options
context:
space:
mode:
Diffstat (limited to 'poi-excelant/src')
-rw-r--r--poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtilFactory.java20
1 files changed, 9 insertions, 11 deletions
diff --git a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtilFactory.java b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtilFactory.java
index 55c4896705..7838a5d6eb 100644
--- a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtilFactory.java
+++ b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtilFactory.java
@@ -27,7 +27,7 @@ import java.util.Map;
*/
public final class ExcelAntWorkbookUtilFactory {
- private static Map<String, ExcelAntWorkbookUtil> workbookUtilMap;
+ private static final Map<String, ExcelAntWorkbookUtil> workbookUtilMap = new HashMap<>();
private ExcelAntWorkbookUtilFactory() {
}
@@ -41,16 +41,14 @@ public final class ExcelAntWorkbookUtilFactory {
* a freshly instantiated one if none did exist before.
*/
public static ExcelAntWorkbookUtil getInstance(String fileName) {
- if(workbookUtilMap == null) {
- workbookUtilMap = new HashMap<>();
+ synchronized (workbookUtilMap) {
+ if(workbookUtilMap.containsKey(fileName)) {
+ return workbookUtilMap.get(fileName);
+ }
+
+ ExcelAntWorkbookUtil wbu = new ExcelAntWorkbookUtil(fileName);
+ workbookUtilMap.put(fileName, wbu);
+ return wbu;
}
-
- if(workbookUtilMap.containsKey(fileName)) {
- return workbookUtilMap.get(fileName);
- }
-
- ExcelAntWorkbookUtil wbu = new ExcelAntWorkbookUtil(fileName);
- workbookUtilMap.put(fileName, wbu);
- return wbu;
}
}