Uploaded image for project: 'Commons Collections'
  1. Commons Collections
  2. COLLECTIONS-323

Behavior of constructors CaseInsensitiveMap inconsistent with standard Java HashMap

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.2
    • 4.0-alpha1, 4.0
    • Map
    • None
    • Any

    Description

      The constructor CaseInsensitiveMap(int initialCapacity) throws an IllegalArgumentException if "the initial capacity is less than one". This is inconsistent with the standard Java HashMap constructor HashMap(int initialCapacity), which throws an if IllegalArgumentException if "the initial capacity is negative".

      Thus:
      new HashMap(0) ==> no exception
      new CaseInsensitiveMap(0) ==> IllegalArgumentException.

      This inconsistency is confusing.

      Actions:

      • Change Javadoc (this shouldn't be a problem in practice since surely there is no code around depending on the fact that the constructor throws an IllegalArgumentException )
      • Change code.

      Attachments

        1. patch.tar.gz
          14 kB
          Michail Giannakopoulos

        Activity

          People

            jochen@apache.org Jochen Wiedmann
            mbrak Maarten Brak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified