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

Replace the Java 7 AssertionError(message, cause) with initCause #3000

Merged
merged 2 commits into from
Jun 2, 2015
Merged
Show file tree
Hide file tree
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
24 changes: 18 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,14 @@ 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));
AssertionError ae = new AssertionError("Multiple errors: " + err.size());
ae.initCause(new CompositeException(err));
throw ae;
} else
if (!clazz.isInstance(err.get(0))) {
throw new AssertionError("Exceptions differ; expected: " + clazz + ", actual: " + err.get(0), err.get(0));
AssertionError ae = new AssertionError("Exceptions differ; expected: " + clazz + ", actual: " + err.get(0));
ae.initCause(err.get(0));
throw ae;
}
}

Expand All @@ -378,10 +382,14 @@ 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));
AssertionError ae = new AssertionError("Multiple errors: " + err.size());
ae.initCause(new CompositeException(err));
throw ae;
} else
if (!throwable.equals(err.get(0))) {
throw new AssertionError("Exceptions differ; expected: " + throwable + ", actual: " + err.get(0), err.get(0));
AssertionError ae = new AssertionError("Exceptions differ; expected: " + throwable + ", actual: " + err.get(0));
ae.initCause(err.get(0));
throw ae;
}
}

Expand All @@ -400,9 +408,13 @@ 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));
AssertionError ae = new AssertionError("Found " + err.size() + " errors and " + s + " completion events instead of none");
ae.initCause(err.get(0));
throw ae;
} else {
throw new AssertionError("Found " + err.size() + " errors and " + s + " completion events instead of none", new CompositeException(err));
AssertionError ae = new AssertionError("Found " + err.size() + " errors and " + s + " completion events instead of none");
ae.initCause(new CompositeException(err));
throw ae;
}
}
}
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();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java 6 compiler is not smart enough to infer Integer.

int sidx = state.index;
if (idx != sidx) {
Integer j = state.replayObserverFromIndex(idx, o);
Expand Down