Alessandro Alinone
When an update event is supplied to Lightstreamer by the Data Adapter through "update" or "smartUpdate", the event object is forwarded by Lightstreamer to worker threads and kept for some unspecified time.
As a consequence, the Data Adapter cannot reuse that object instance anymore, otherwise race conditions between reads by Lightstreamer and further modifications of the object by the Data Adapter could happen and Lightstreamer might find the update event object in an inconsistent state.
The above holds for all types of event objects supported (namely, ItemEvent, OldItemEvent and all Map subtypes).
However, if the object class is not thread safe, this also means that, in case the Data Adapter tried to reuse an event object, the object might be accessed in a improper way.
In fact, in case of reuse, even if the Data Adapter explicitly synchronized its own accesses to the object, it would be possible that an access by Lightstreamer and an access by the Data Adapter happen concurrently.
The consequences of concurrent accesses to a non-thread-safe object can be unpredictable and the final effect can be of a totally different nature and difficult to investigate.
This is the case of HashMap, which is the most common event object type.
The curruption introduced into a HashMap object by lack of synchronization can be as bad as causing calls to get() and contains() to get stuck in endless loops.
The race condition could be exploited at any moment and once a loop is entered, it might also cause important locks to be kept, leading to internal buffers growth, thread pools exhaustion and the whole system to become
Although using ConcurrentHashMap in place of HashMap prevents all synchronization problems, you might prefer to stick to HashMap because of performance reasons.
Hence, it is important to stress that the Data Adapter must take care that concurrent accesses to the same HashMap instance are not possible and, in particular, that HashMap instances are no longer accessed after they are supplied to "update" or "smartUpdate".