* 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];
*
* @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);
}
}
}