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

Collections.unmodifiableCollection(Collection source) accepts null argument

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • None
    • 1.3.0
    • core-libs

    Description



      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)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: