-
Notifications
You must be signed in to change notification settings - Fork 111
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
base: master
Are you sure you want to change the base?
Conversation
@@ -175,8 +176,10 @@ public boolean isLogDisabled() { | |||
return logDisabled; | |||
} | |||
|
|||
public LogBuffer<LogMultipleRecord> getBuffer() { | |||
return buffer; | |||
public void withBuffer(Consumer<LogBuffer<LogMultipleRecord>> bufferConsumer) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
As per MANGO-1975
As per MANGO-1975
|
Found problems with 2 randomly failing test classes:
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:
com.serotonin.bacnet4j.obj.logBuffer.LogBuffer
class. (Need to look at other tests)com.serotonin.bacnet4j.obj.EventNotifListener
as 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.