Skip to content

Commit

Permalink
Replace the Java 7 AssertionError(message, cause) with RuntimeException
Browse files Browse the repository at this point in the history
  • Loading branch information
zsxwing committed Jun 2, 2015
1 parent 34dce48 commit a22cce7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/main/java/rx/observers/TestSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,12 @@ public void assertError(Class<? extends Throwable> clazz) {
throw new AssertionError("No errors");
} else
if (err.size() > 1) {
throw new AssertionError("Multiple errors: " + err.size(), new CompositeException(err));
// can't use AssertionError because (message, cause) doesn't exist until Java 7
throw new RuntimeException("Multiple errors: " + err.size(), new CompositeException(err));
} else
if (!clazz.isInstance(err.get(0))) {
throw new AssertionError("Exceptions differ; expected: " + clazz + ", actual: " + err.get(0), err.get(0));
// can't use AssertionError because (message, cause) doesn't exist until Java 7
throw new RuntimeException("Exceptions differ; expected: " + clazz + ", actual: " + err.get(0), err.get(0));
}
}

Expand All @@ -378,10 +380,12 @@ public void assertError(Throwable throwable) {
throw new AssertionError("No errors");
} else
if (err.size() > 1) {
throw new AssertionError("Multiple errors: " + err.size(), new CompositeException(err));
// can't use AssertionError because (message, cause) doesn't exist until Java 7
throw new RuntimeException("Multiple errors: " + err.size(), new CompositeException(err));
} else
if (!throwable.equals(err.get(0))) {
throw new AssertionError("Exceptions differ; expected: " + throwable + ", actual: " + err.get(0), err.get(0));
// can't use AssertionError because (message, cause) doesn't exist until Java 7
throw new RuntimeException("Exceptions differ; expected: " + throwable + ", actual: " + err.get(0), err.get(0));
}
}

Expand All @@ -400,9 +404,11 @@ public void assertNoTerminalEvent() {
throw new AssertionError("Found " + err.size() + " errors and " + s + " completion events instead of none");
} else
if (err.size() == 1) {
throw new AssertionError("Found " + err.size() + " errors and " + s + " completion events instead of none", err.get(0));
// can't use AssertionError because (message, cause) doesn't exist until Java 7
throw new RuntimeException("Found " + err.size() + " errors and " + s + " completion events instead of none", err.get(0));
} else {
throw new AssertionError("Found " + err.size() + " errors and " + s + " completion events instead of none", new CompositeException(err));
// can't use AssertionError because (message, cause) doesn't exist until Java 7
throw new RuntimeException("Found " + err.size() + " errors and " + s + " completion events instead of none", new CompositeException(err));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rx/subjects/ReplaySubject.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void call(SubjectObserver<T> o) {
boolean skipFinal = false;
try {
for (;;) {
int idx = o.index();
int idx = o.<Integer>index();
int sidx = state.index;
if (idx != sidx) {
Integer j = state.replayObserverFromIndex(idx, o);
Expand Down

0 comments on commit a22cce7

Please sign in to comment.