From 8ab3be71a3ebc5667c402c2b6e6458cb73bce616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Andr=C3=A9=20Pearce?= Date: Wed, 26 Sep 2018 21:11:24 +0100 Subject: [PATCH] ARTEMIS-2099 Avoid possible double instantiation of properties --- .../artemis/core/message/impl/CoreMessage.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java index cc79c2c830..b548b29861 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java @@ -551,12 +551,16 @@ public class CoreMessage extends RefCountMessage implements ICoreMessage { */ protected TypedProperties checkProperties() { if (properties == null) { - TypedProperties properties = new TypedProperties(); - if (buffer != null && propertiesLocation >= 0) { - final ByteBuf byteBuf = buffer.duplicate().readerIndex(propertiesLocation); - properties.decode(byteBuf, coreMessageObjectPools == null ? null : coreMessageObjectPools.getPropertiesDecoderPools()); + synchronized (this) { + if (properties == null) { + TypedProperties properties = new TypedProperties(); + if (buffer != null && propertiesLocation >= 0) { + final ByteBuf byteBuf = buffer.duplicate().readerIndex(propertiesLocation); + properties.decode(byteBuf, coreMessageObjectPools == null ? null : coreMessageObjectPools.getPropertiesDecoderPools()); + } + this.properties = properties; + } } - this.properties = properties; } return this.properties;