From c5986447d18d6bb3a06f5a31888a244355c963ac Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 15 Oct 2024 16:16:51 +0000 Subject: thread safety git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1921339 13f79535-47bb-0310-9956-ffa450edef68 --- poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/Borders.java | 7 +++++-- .../main/java/org/apache/poi/xwpf/usermodel/UnderlinePatterns.java | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/Borders.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/Borders.java index f2763f4fab..2ab27d37da 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/Borders.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/Borders.java @@ -17,6 +17,7 @@ package org.apache.poi.xwpf.usermodel; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -598,12 +599,14 @@ public enum Borders { ZIG_ZAG_STITCH(191); - private static Map imap = new HashMap<>(); + private static final Map imap; static { + final Map tempMap = new HashMap<>(); for (Borders p : values()) { - imap.put(Integer.valueOf(p.getValue()), p); + tempMap.put(Integer.valueOf(p.getValue()), p); } + imap = Collections.unmodifiableMap(tempMap); } private final int value; diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/UnderlinePatterns.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/UnderlinePatterns.java index 0e27f429f3..05eb5d422f 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/UnderlinePatterns.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/UnderlinePatterns.java @@ -16,6 +16,7 @@ ==================================================================== */ package org.apache.poi.xwpf.usermodel; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -133,12 +134,14 @@ public enum UnderlinePatterns { */ NONE(18); - private static Map imap = new HashMap<>(); + private static final Map imap; static { + final Map tempMap = new HashMap<>(); for (UnderlinePatterns p : values()) { - imap.put(p.getValue(), p); + tempMap.put(p.getValue(), p); } + imap = Collections.unmodifiableMap(tempMap); } private final int value; -- cgit v1.2.3