FEST
  1. FEST
  2. FEST-378

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

    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
    • Number of attachments :
      0

      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

        Yvonne Wang made changes -
        Field Original Value New Value
        Assignee Alex Ruiz [ alexruiz ]
        Fix Version/s FEST-Assert 1.3.1 [ 16677 ]
        Alex Ruiz made changes -
        Original Estimate 0 minutes [ 0 ]
        Remaining Estimate 0 minutes [ 0 ]
        Alex Ruiz made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Alex Ruiz added a comment -

        Fix can be viewed at GitHub.

        Show
        Alex Ruiz added a comment - Fix can be viewed at GitHub .
        Alex Ruiz made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Alex Ruiz
            Reporter:
            Mark Derricutt
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: