BACnet4J
BACnet4J copied to clipboard
Fix concurrency issues in tests to make build stable.
Found problems with 2 randomly failing test classes:
- TrendLogObjecTest
- TrendLogMultipleObjectTest
The problem was due to accessing a non thread safe collection of the trend logs in the tests. The solution fixes the tests by wrapping access in a synchronization block and exposing a utility method to check size of list in a thread safe way.
I suspect there are more problems but I've run the tests thousands of times and seem to have rooted out most of the problems with these 2 classes. I suspect there may still be problems with:
- Anything that tests an Object that uses the
com.serotonin.bacnet4j.obj.logBuffer.LogBufferclass. (Need to look at other tests) - The parts of the tests that use a
com.serotonin.bacnet4j.obj.EventNotifListeneras this collection is also not thread safe.
Note
Before closing this out we should create some work that will review the internal use of the LogBuffer class as it is definitely not thread safe and can potentially be accessed in a non-thread-safe way via its interface.
Quality Gate failed
Failed conditions
C Reliability Rating on New Code (required ≥ A)
See analysis details on SonarQube Cloud
Catch issues before they fail your Quality Gate with our IDE extension
SonarQube for IDE