aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--poi/src/main/java/org/apache/poi/hpsf/VariantSupport.java22
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);
}
}
}