AMQ-7439: AbstractMQTTSocket#getProtocolConverter: Race condition in double-checked locking object initialization

protocolConverter may be visible to other threads before its properties are set.
This commit is contained in:
Pascal Schumacher 2020-03-08 11:10:40 +01:00
parent 4a4880301f
commit 8fa772c8de
1 changed files with 3 additions and 2 deletions

View File

@ -144,8 +144,9 @@ public abstract class AbstractMQTTSocket extends TransportSupport implements MQT
if (protocolConverter == null) {
synchronized(this) {
if (protocolConverter == null) {
protocolConverter = new MQTTProtocolConverter(this, brokerService);
IntrospectionSupport.setProperties(protocolConverter, transportOptions);
MQTTProtocolConverter newProtocolConverter = new MQTTProtocolConverter(this, brokerService);
IntrospectionSupport.setProperties(newProtocolConverter, transportOptions);
protocolConverter = newProtocolConverter;
}
}
}