The records, lists, and listeners HashMaps of RecordHandler are accessed and modified in non-thread safe ways. There is an attempt in some places to make it thread safe with the following double checked pattern:
Record record = records.get( name );
if( record == null ) {
synchronized (this) {
record = records.get( name );
if (record == null) {
record = new Record(name, new HashMap(), connection, deepstreamConfig, client);
records.put(name, record);
...
But that allows HashMap.get to happen simultaneously with HashMap.put. The HashMap javadocs are very clear on this:
If multiple threads access a hash map concurrently, and at least one of the threads modifies the map structurally, it must be synchronized externally.
The
records
,lists
, andlisteners
HashMaps ofRecordHandler
are accessed and modified in non-thread safe ways. There is an attempt in some places to make it thread safe with the following double checked pattern:But that allows
HashMap.get
to happen simultaneously withHashMap.put
. TheHashMap
javadocs are very clear on this: