]> source.dussan.org Git - poi.git/commitdiff
[github-709] Make BitFieldFactory threadsafe. Thanks to ZhangChen. This closes #709
authorPJ Fanning <fanningpj@apache.org>
Tue, 15 Oct 2024 12:58:33 +0000 (12:58 +0000)
committerPJ Fanning <fanningpj@apache.org>
Tue, 15 Oct 2024 12:58:33 +0000 (12:58 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1921332 13f79535-47bb-0310-9956-ffa450edef68

poi/src/main/java/org/apache/poi/util/BitFieldFactory.java

index 4893d5e61bccd9338d74ffcc43bcb9b0200cf874..40e69cb0bdcf4196aabfca433332110ffd80ed4d 100644 (file)
 
 package org.apache.poi.util;
 
-import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * Returns immutable Bitfield instances.
  */
 public class BitFieldFactory {
-    private static Map<Integer, BitField> instances = new HashMap<>();
+    private static final ConcurrentHashMap<Integer, BitField> instances = new ConcurrentHashMap<>();
 
     public static BitField getInstance(int mask) {
         return instances.computeIfAbsent(mask, k -> new BitField(mask));