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

Return copies in ShadowLog#getLogs and ShadowLog#getLogsForTag #3007

Merged
merged 1 commit into from Apr 10, 2017

Conversation

hoisie
Copy link
Contributor

@hoisie hoisie commented Apr 1, 2017

Previously, ShadowLog#getLogs and ShadowLog#getLogsForTag would return
the raw underlying data structure used to store the logs. This could
cause ConcurrentModificationExceptions if a test iterated over these
structures while another thread added more data to the logs.

Instead, return a copy of the logs each time ShadowLog#getLogs and
ShadowLog#getLogsForTag is called. This prevents tests from accidentally
interfering with the data and causing problems.

Also, update the data structures to be concurrent. Store logs in a
concurrent queue, and use synchronized structures for maps. This
eliminates the need to use class synchronization.

Previously, ShadowLog#getLogs and ShadowLog#getLogsForTag would return
the raw underlying data structure used to store the logs. This could
cause ConcurrentModificationExceptions if a test iterated over these
structures while another thread added more data to the logs.

Instead, return a copy of the logs each time ShadowLog#getLogs and
ShadowLog#getLogsForTag is called. This prevents tests from accidentally
interfering with the data and causing problems.

Also, update the data structures to be concurrent. Store logs in a
concurrent queue, and use synchronized structures for maps. This
eliminates the need to use class synchronization.
@jongerrish jongerrish merged commit 64c3475 into robolectric:master Apr 10, 2017
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.

None yet

2 participants