Description
Comparing an instance of PageParameters with some parameters set to an empty PageParameters instance results in a NullPointerException.
This bug was introduced by WICKET-6283 where collection equality was replaced by CollectionUtils.isEmptyCollection(). The latter API expects both arguments to be non-null, while the former accepts nulls.
Test case:
/** * namedParameters equality should handle null namedParameters instance. */ @Test public void equalityWithEmptyParameters() { PageParameters p1 = new PageParameters() .add("a", "b"); PageParameters p2 = new PageParameters(); assertThat(p1, is(not(equalTo(p2)))); }
Output:
java.lang.NullPointerException at org.apache.commons.collections4.CollectionUtils.isEqualCollection(CollectionUtils.java:515) at org.apache.wicket.request.mapper.parameter.PageParameters.equals(PageParameters.java:470) at org.hamcrest.core.IsEqual.areEqual(IsEqual.java:40) at org.hamcrest.core.IsEqual.matches(IsEqual.java:23) at org.hamcrest.core.IsNot.matches(IsNot.java:22) at org.hamcrest.core.Is.matches(Is.java:26) at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:10) at org.junit.Assert.assertThat(Assert.java:956) at org.junit.Assert.assertThat(Assert.java:923) at org.apache.wicket.request.mapper.parameter.PageParametersTest.equalityWithEmptyParameters(PageParametersTest.java:328)
Attachments
Attachments
Issue Links
- relates to
-
WICKET-6283 Page parameter equality should not depend on named parameters order
- Resolved