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

arrayContaining(null, null) cause NullPointerException #25

Closed
Megaprog opened this issue Jan 18, 2013 · 2 comments
Closed

arrayContaining(null, null) cause NullPointerException #25

Megaprog opened this issue Jan 18, 2013 · 2 comments
Assignees
Labels

Comments

@Megaprog
Copy link

Has hamcrest 1.3 and junit 4.11

Code:

Object[] objects = new Object[] {null, null};
assertThat(objects, arrayContaining(null, null));

cause NullPointerException:

java.lang.NullPointerException
at org.hamcrest.collection.IsIterableContainingInOrder$MatchSeries.isMatched(IsIterableContainingInOrder.java:65)
at org.hamcrest.collection.IsIterableContainingInOrder$MatchSeries.matches(IsIterableContainingInOrder.java:52)
at org.hamcrest.collection.IsIterableContainingInOrder.matchesSafely(IsIterableContainingInOrder.java:25)
at org.hamcrest.collection.IsIterableContainingInOrder.matchesSafely(IsIterableContainingInOrder.java:14)
at org.hamcrest.TypeSafeDiagnosingMatcher.matches(TypeSafeDiagnosingMatcher.java:55)
at org.hamcrest.collection.IsArrayContainingInOrder.matchesSafely(IsArrayContainingInOrder.java:26)
at org.hamcrest.collection.IsArrayContainingInOrder.matchesSafely(IsArrayContainingInOrder.java:15)
at org.hamcrest.TypeSafeMatcher.matches(TypeSafeMatcher.java:65)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:12)
at org.junit.Assert.assertThat(Assert.java:865)
at org.junit.Assert.assertThat(Assert.java:832)

@sf105
Copy link
Member

sf105 commented Jan 27, 2013

The problem is that overloading is picking up arrayContaining(Matcher matcher) rather than arrayContaining(T object). I need to add some kind of null check.

@ghost ghost assigned sf105 Mar 14, 2013
@sf105
Copy link
Member

sf105 commented Mar 14, 2013

fixed in commit 40465aa

@sf105 sf105 closed this as completed Mar 14, 2013
npathai added a commit to npathai/JavaHamcrest that referenced this issue Nov 2, 2014
npryce added a commit that referenced this issue Nov 23, 2014
Fixed Issue #69 by adding null safe check similar to the one in issue #25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants