You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Alexey Grigorovitch (JIRA)" <ji...@apache.org> on 2017/03/06 05:55:32 UTC

[jira] [Created] (WICKET-6332) NullPointerException in PageParameters#equals()

Alexey Grigorovitch created WICKET-6332:
-------------------------------------------

             Summary: NullPointerException in PageParameters#equals()
                 Key: WICKET-6332
                 URL: https://issues.apache.org/jira/browse/WICKET-6332
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 8.0.0-M4, 7.6.0
            Reporter: Alexey Grigorovitch


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:
{code}
	/**
         * 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))));
	}
{code}

Output:
{noformat}
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)
{noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)