Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix concurrency issues in tests to make build stable. #113

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

terrypacker
Copy link

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.

@@ -175,8 +176,10 @@ public boolean isLogDisabled() {
return logDisabled;
}

public LogBuffer<LogMultipleRecord> getBuffer() {
return buffer;
public void withBuffer(Consumer<LogBuffer<LogMultipleRecord>> bufferConsumer) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the 2 changes that make the tests pass, accessing the buffer in a thread safe manner.

@@ -204,8 +205,10 @@ public boolean isLogDisabled() {
return logDisabled;
}

public LogBuffer<LogRecord> getBuffer() {
return buffer;
public void withBuffer(Consumer<LogBuffer<LogRecord>> bufferConsumer) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the 2 changes that make the tests pass, accessing the buffer in a thread safe manner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant