Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4288125

Collections.unmodifiableCollection(Collection source) accepts null argument

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.3.0
    • 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)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: