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

2.x: BaseTestConsumer values() and errors() thread-safety clarifications #5713

Merged
merged 1 commit into from
Nov 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/main/java/io/reactivex/observers/BaseTestConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ public final Thread lastThread() {

/**
* Returns a shared list of received onNext values.
* <p>
* Note that accessing the items via certain methods of the {@link List}
* interface while the upstream is still actively emitting
* more items may result in a {@code ConcurrentModificationException}.
* <p>
* The {@link List#size()} method will return the number of items
* already received by this TestObserver/TestSubscriber in a thread-safe
* manner that can be read via {@link List#get(int)}) method
* (index range of 0 to {@code List.size() - 1}).
* <p>
* A view of the returned List can be created via {@link List#subList(int, int)}
* by using the bounds 0 (inclusive) to {@link List#size()} (exclusive) which,
* when accessed in a read-only fashion, should be also thread-safe and not throw any
* {@code ConcurrentModificationException}.
* @return a list of received onNext values
*/
public final List<T> values() {
Expand All @@ -83,6 +97,20 @@ public final List<T> values() {

/**
* Returns a shared list of received onError exceptions.
* <p>
* Note that accessing the errors via certain methods of the {@link List}
* interface while the upstream is still actively emitting
* more items or errors may result in a {@code ConcurrentModificationException}.
* <p>
* The {@link List#size()} method will return the number of errors
* already received by this TestObserver/TestSubscriber in a thread-safe
* manner that can be read via {@link List#get(int)}) method
* (index range of 0 to {@code List.size() - 1}).
* <p>
* A view of the returned List can be created via {@link List#subList(int, int)}
* by using the bounds 0 (inclusive) to {@link List#size()} (exclusive) which,
* when accessed in a read-only fashion, should be also thread-safe and not throw any
* {@code ConcurrentModificationException}.
* @return a list of received events onError exceptions
*/
public final List<Throwable> errors() {
Expand Down