Skip to content

Commit a772a7e

Browse files
author
Brian Attwell
committed
Apply leak test to the size portion of the TimeoutAndSize tests
1 parent 2b60da4 commit a772a7e

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/main/java/io/reactivex/internal/operators/observable/ObservableReplay.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,9 @@ void truncateFinal() {
739739
/* test */ final void collectValuesInMemory(Collection<? super T> output) {
740740
Node next = getHead();
741741
for (;;) {
742-
if (next != null) {
742+
if (next == null) {
743+
break;
744+
} else if (next.value != null) {
743745
Object o = next.value;
744746
Object v = leaveTransform(o);
745747
if (NotificationLite.isComplete(v) || NotificationLite.isError(v)) {
@@ -749,8 +751,6 @@ void truncateFinal() {
749751
if (value != null) {
750752
output.add(value);
751753
}
752-
} else {
753-
break;
754754
}
755755
next = next.get();
756756
}

src/test/java/io/reactivex/internal/operators/observable/ObservableReplayTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313

1414
package io.reactivex.internal.operators.observable;
15-
1615
import static org.junit.Assert.*;
1716
import static org.mockito.ArgumentMatchers.*;
1817
import static org.mockito.Mockito.*;
@@ -766,8 +765,7 @@ public void testTimedAndSizedTruncation() {
766765

767766
buf.next(3);
768767
buf.next(4);
769-
values.clear();
770-
buf.collect(values);
768+
collectAndAssertNoLeaks(buf, values);
771769
Assert.assertEquals(Arrays.asList(3, 4), values);
772770

773771
test.advanceTimeBy(2, TimeUnit.SECONDS);
@@ -809,8 +807,7 @@ public void testTimedAndSizedTruncationError() {
809807

810808
buf.next(3);
811809
buf.next(4);
812-
values.clear();
813-
buf.collect(values);
810+
collectAndAssertNoLeaks(buf, values);
814811
Assert.assertEquals(Arrays.asList(3, 4), values);
815812

816813
test.advanceTimeBy(2, TimeUnit.SECONDS);

0 commit comments

Comments
 (0)