mirror of https://github.com/apache/poi.git
try to make ExcelAntWorkbookUtilFactory thread safe
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1921338 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
88a0d4ecf3
commit
fad6cae019
|
@ -27,7 +27,7 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public final class ExcelAntWorkbookUtilFactory {
|
public final class ExcelAntWorkbookUtilFactory {
|
||||||
|
|
||||||
private static Map<String, ExcelAntWorkbookUtil> workbookUtilMap;
|
private static final Map<String, ExcelAntWorkbookUtil> workbookUtilMap = new HashMap<>();
|
||||||
|
|
||||||
private ExcelAntWorkbookUtilFactory() {
|
private ExcelAntWorkbookUtilFactory() {
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,7 @@ public final class ExcelAntWorkbookUtilFactory {
|
||||||
* a freshly instantiated one if none did exist before.
|
* a freshly instantiated one if none did exist before.
|
||||||
*/
|
*/
|
||||||
public static ExcelAntWorkbookUtil getInstance(String fileName) {
|
public static ExcelAntWorkbookUtil getInstance(String fileName) {
|
||||||
if(workbookUtilMap == null) {
|
synchronized (workbookUtilMap) {
|
||||||
workbookUtilMap = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(workbookUtilMap.containsKey(fileName)) {
|
if(workbookUtilMap.containsKey(fileName)) {
|
||||||
return workbookUtilMap.get(fileName);
|
return workbookUtilMap.get(fileName);
|
||||||
}
|
}
|
||||||
|
@ -54,3 +51,4 @@ public final class ExcelAntWorkbookUtilFactory {
|
||||||
return wbu;
|
return wbu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
package org.apache.poi.xwpf.usermodel;
|
package org.apache.poi.xwpf.usermodel;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -45,12 +46,14 @@ public enum VerticalAlign {
|
||||||
*/
|
*/
|
||||||
SUBSCRIPT(3);
|
SUBSCRIPT(3);
|
||||||
|
|
||||||
private static final Map<Integer, VerticalAlign> imap = new HashMap<>();
|
private static final Map<Integer, VerticalAlign> imap;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
final Map<Integer, VerticalAlign> tempMap = new HashMap<>();
|
||||||
for (VerticalAlign p : values()) {
|
for (VerticalAlign p : values()) {
|
||||||
imap.put(p.getValue(), p);
|
tempMap.put(p.getValue(), p);
|
||||||
}
|
}
|
||||||
|
imap = Collections.unmodifiableMap(tempMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
Loading…
Reference in New Issue