BACnet4J icon indicating copy to clipboard operation
BACnet4J copied to clipboard

Fix concurrency issues in tests to make build stable.

Open terrypacker opened this issue 9 months ago • 1 comments

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:

  1. Anything that tests an Object that uses the com.serotonin.bacnet4j.obj.logBuffer.LogBuffer class. (Need to look at other tests)
  2. The parts of the tests that use a com.serotonin.bacnet4j.obj.EventNotifListener as this collection is also not thread safe.

image

image

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.

terrypacker avatar Feb 12 '25 21:02 terrypacker

Quality Gate Failed 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

sonarqubecloud[bot] avatar Mar 21 '25 20:03 sonarqubecloud[bot]