deepstream.io-client-java icon indicating copy to clipboard operation
deepstream.io-client-java copied to clipboard

This client library has widespread thread safety issues

Open fhriley opened this issue 9 years ago • 0 comments

Following on to issue #109, I figured I should look to see if these same thread safety issues were in other parts of this library. Sure enough, the first two classes I looked at, UtilEmitter and UtilAckTimeoutRegistry, both have these same kinds of thread safety issues. They do use Concurrent* collections in a lot of places, but that alone does not make them thread safe. For example, this seems to be common:

Concurrent* foo;
obj = foo.get()
if (obj == null) {
    foo.put(...);
}

This is not thread safe. One thread could preempt after the obj == null and then a second thread could come through and do the put. The first thread would then resume and also do the put.

It appears this library needs to be gone through class by class to address thread safety. This is a serious issue that needs to be addressed ASAP if this library is to be used for projects that are highly concurrent. Trading apps come to mind (lots and lots of quotes coming in).

fhriley avatar Oct 13 '17 01:10 fhriley