Documentation issue maybe

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Documentation issue maybe

Romain Gilles
Hi all,

The class CollectSink is not thread safe as only the write to the values collection are synchronized but not the read: CollectSink.values.containsAll(...). Maybe if you use a CopyOnWriteArrayList instead of an ArrayList and remove the synchronized key work it should be ok.

Romain
Reply | Threaded
Open this post in threaded view
|

Re: Documentation issue maybe

Zhenghua Gao
Your are right that it's not thread-safety.
I think we can use Collections.synchronizedList() to get a thread-safety list[1].
And remove the synchronized keyword from the invoke interface.

I have created a ticket to track this[2], please feel free to fix it by make a pull request.


Best Regards,
Zhenghua Gao


On Thu, Nov 7, 2019 at 12:12 AM Romain Gilles <[hidden email]> wrote:
Hi all,

The class CollectSink is not thread safe as only the write to the values collection are synchronized but not the read: CollectSink.values.containsAll(...). Maybe if you use a CopyOnWriteArrayList instead of an ArrayList and remove the synchronized key work it should be ok.

Romain