Skip to content

Commit

Permalink
Change generics on ExpectedException.expectCause().
Browse files Browse the repository at this point in the history
The previous generics (Matcher<? extends Throwable>) would not allow
you do use matchers on Object, like notNullValue().

Fixes junit-team#1073
  • Loading branch information
kcooney authored and stefanbirkner committed Dec 1, 2016
1 parent 0c1269e commit 9259546
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
public class ThrowableCauseMatcher<T extends Throwable> extends
TypeSafeMatcher<T> {

private final Matcher<? extends Throwable> causeMatcher;
private final Matcher<?> causeMatcher;

public ThrowableCauseMatcher(Matcher<? extends Throwable> causeMatcher) {
public ThrowableCauseMatcher(Matcher<?> causeMatcher) {
this.causeMatcher = causeMatcher;
}

Expand Down Expand Up @@ -46,7 +46,7 @@ protected void describeMismatchSafely(T item, Description description) {
* @param <T> type of the outer exception
*/
@Factory
public static <T extends Throwable> Matcher<T> hasCause(final Matcher<? extends Throwable> matcher) {
public static <T extends Throwable> Matcher<T> hasCause(final Matcher<?> matcher) {
return new ThrowableCauseMatcher<T>(matcher);
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/junit/rules/ExpectedException.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public ExpectedException expectMessage(Matcher<String> matcher) {
* @deprecated use {@code org.hamcrest.junit.ExpectedException.expectCause()}
*/
@Deprecated
public ExpectedException expectCause(Matcher<? extends Throwable> expectedCause) {
public ExpectedException expectCause(Matcher<?> expectedCause) {
expect(hasCause(expectedCause));
return this;
}
Expand Down

0 comments on commit 9259546

Please sign in to comment.