tango-controls / JTango

TANGO kernel Java implementation. JTango moved to https://gitlab.com/tango-controls/JTango
http://tango-controls.org
8 stars 14 forks source link

Vectors refactoring in DbAttribute #109

Closed KrystianKedron closed 3 years ago

KrystianKedron commented 3 years ago

Refactoring to use ArrayList instead of Vector for fr.esrf.TangoApi package.

Also small sonar fixes.

Ingvord commented 3 years ago

The main difference between Vector and ArrayList in Java is that the later one is not thread safe while Vector is synchronous by design link. Please address concurrency issues in this PR.

KrystianKedron commented 3 years ago

@Ingvord thanks for your comment.

Yes, exactly this is the main difference. Scarcely I started working on this topic, and this PR isn't completed ("Draft"). I base on the information that I found here https://github.com/tango-controls/JTango/issues/94 -> "where thread safety is not an issue (and it does not seem to be the case in JTango core)". So to provided something I refactoring first class and validated my changes in unit tests on the class level.

My next target is to create the integration tests and use the AttributePoxy/DeviceProxy to see that everything works as expected.

Also, I start analyzing where the DbAttribute is used and checking that some synchronization mechanism is required. I plan to use the synchronized block. Or, we can add the synchronized keyword to the methods in the DbAttribute (this will be a simple way to make DbAttribute thread-safe). Or use CopyOnWriteArrayList instead ArrayList. Also is possible to create the List by Collections.synchronizedList() static method. What direction do you recommend?

Also, any hints where (in which package)/classes the synchronization will be also required will be very welcome.

Pascal-Verdier commented 3 years ago

OK for me. I merged it.