Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6332

NullPointerException in PageParameters#equals()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 7.6.0, 8.0.0-M4
    • 7.7.0, 8.0.0-M9
    • wicket
    • None

    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

        Issue Links

          Activity

            People

              mgrigorov Martin Tzvetanov Grigorov
              alexey.grigorovich Alexey Grigorovitch
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: