jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • FEST
  • FEST-378

Newly added assertThat(Iterable<?> actual) eagerly calls iterator() and can throw an NPE

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: FEST-Assert 1.3
  • Fix Version/s: FEST-Assert 1.4
  • Component/s: None
  • Labels:
    None

Description

Under FEST-Assertions 1.3 a new assertThat() method was added that takes an Iterable, in my custom extension I have:

public LdapEntryAssertion doesNotExist() {
    assertThat(entry)
            .describedAs(entryName + " doe not exist in LDAP")
            .isNull();
    return this;
}

In this instance, the entry variable may or may not be null. It turns out the Class of this object implements Iterable and whilst previous would fall under the assertThat(Object) method, it nows hits assertThat(Iterable).

assertThat(Iterable) eagerly calls #iterator inorder to create a collection. This should probably be null safe with something like:

public static CollectionAssert assertThat(Iterable<?> actual) {
  return actual != null ? assertThat(asCollection(actual.iterator())) : assertThat(actual);
}

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Alex Ruiz added a comment - 06/Sep/10 11:29 PM

Fix can be viewed at GitHub.

Show
Alex Ruiz added a comment - 06/Sep/10 11:29 PM Fix can be viewed at GitHub.

People

  • Assignee:
    Alex Ruiz
    Reporter:
    Mark Derricutt
Vote (0)
Watch (0)

Dates

  • Created:
    05/Aug/10 8:38 PM
    Updated:
    06/Sep/10 11:29 PM
    Resolved:
    06/Sep/10 11:29 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.