Skip to content

Commit 30da1aa

Browse files
vyakarnokd
authored andcommitted
Throw unchecked exception in TestSubscriber#awaitValueCount(). (#4453)
1 parent 70bb06a commit 30da1aa

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/main/java/rx/observers/TestSubscriber.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,17 @@ private void assertItem(T expected, int i) {
355355
* @param timeout the time to wait for the events
356356
* @param unit the time unit of waiting
357357
* @return true if the expected number of onNext events happened
358-
* @throws InterruptedException if the sleep is interrupted
358+
* @throws RuntimeException if the sleep is interrupted
359359
* @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
360360
*/
361361
@Experimental
362-
public final boolean awaitValueCount(int expected, long timeout, TimeUnit unit) throws InterruptedException {
362+
public final boolean awaitValueCount(int expected, long timeout, TimeUnit unit) {
363363
while (timeout != 0 && valueCount < expected) {
364-
unit.sleep(1);
364+
try {
365+
unit.sleep(1);
366+
} catch (InterruptedException e) {
367+
throw new IllegalStateException("Interrupted", e);
368+
}
365369
timeout--;
366370
}
367371
return valueCount >= expected;

src/test/java/rx/observers/TestSubscriberTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ public void completionCount() {
750750
}
751751

752752
@Test
753-
public void awaitValueCount() throws Exception {
753+
public void awaitValueCount() {
754754
TestSubscriber<Integer> ts = TestSubscriber.create();
755755

756756
Observable.range(1, 5).delay(100, TimeUnit.MILLISECONDS)
@@ -763,7 +763,7 @@ public void awaitValueCount() throws Exception {
763763
}
764764

765765
@Test
766-
public void awaitValueCountFails() throws Exception {
766+
public void awaitValueCountFails() {
767767
TestSubscriber<Integer> ts = TestSubscriber.create();
768768

769769
Observable.range(1, 2).delay(100, TimeUnit.MILLISECONDS)

0 commit comments

Comments
 (0)