Collections.unmodifiableCollection(Collection source) accepts null argument

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P3
    • None
    • Affects Version/s: 1.3.0
    • Component/s: core-libs



      Name: krT82822 Date: 11/04/99


      Collections.unmodifiableCollection(Collection source) accepts null argument.
      If you call size() of the returned collection, a NullPointerException is thrown,
      because the unmodifiable collection calls source.size(), and source is null.

      I would recommend to change result of Collections.unmodifiableCollection using
      Collections.EMPTY_LIST (or, better, something like Collections.EMPTY_COLLECTION)
      if a null argument is passed to the method.
      (Review ID: 97358)
      ======================================================================

            Assignee:
            Josh Bloch (Inactive)
            Reporter:
            Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: