diff options
author | PJ Fanning <fanningpj@apache.org> | 2024-10-15 16:39:09 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2024-10-15 16:39:09 +0000 |
commit | 24452a2ecb1a58d01885f574ea6f26e0514ac635 (patch) | |
tree | 82df97cf7f26c78a7fa878b72612dac102c58633 /poi | |
parent | 822974aadc69be4482b710505fae4b220eecf29c (diff) | |
download | poi-24452a2ecb1a58d01885f574ea6f26e0514ac635.tar.gz poi-24452a2ecb1a58d01885f574ea6f26e0514ac635.zip |
try to make VariantSupport thread safe
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1921341 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r-- | poi/src/main/java/org/apache/poi/hpsf/VariantSupport.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/poi/src/main/java/org/apache/poi/hpsf/VariantSupport.java b/poi/src/main/java/org/apache/poi/hpsf/VariantSupport.java index f6da239c8b..39ef7e2431 100644 --- a/poi/src/main/java/org/apache/poi/hpsf/VariantSupport.java +++ b/poi/src/main/java/org/apache/poi/hpsf/VariantSupport.java @@ -66,7 +66,7 @@ public class VariantSupport extends Variant { * Keeps a list of the variant types an "unsupported" message has already * been issued for. */ - private static List<Long> unsupportedMessage; + private static final List<Long> unsupportedMessage = new LinkedList<>(); private static final byte[] paddingBytes = new byte[3]; @@ -102,18 +102,18 @@ public class VariantSupport extends Variant { * * @param ex The exception to log */ - protected static void writeUnsupportedTypeMessage - (final UnsupportedVariantTypeException ex) { - if (isLogUnsupportedTypes()) - { - if (unsupportedMessage == null) { - unsupportedMessage = new LinkedList<>(); + protected static void writeUnsupportedTypeMessage(final UnsupportedVariantTypeException ex) { + if (isLogUnsupportedTypes()) { + final Long vt = ex.getVariantType(); + boolean needsLogging = false; + synchronized (unsupportedMessage) { + if (!unsupportedMessage.contains(vt)) { + needsLogging = true; + unsupportedMessage.add(vt); + } } - Long vt = Long.valueOf(ex.getVariantType()); - if (!unsupportedMessage.contains(vt)) - { + if (needsLogging) { LOG.atError().withThrowable(ex).log("Unsupported type"); - unsupportedMessage.add(vt); } } } |