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;