commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 13758] New: - SequencedHashMap.indexOf(Object key) throws annoying exceptions
Date Fri, 18 Oct 2002 09:10:35 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13758>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13758

SequencedHashMap.indexOf(Object key) throws annoying exceptions

           Summary: SequencedHashMap.indexOf(Object key) throws annoying
                    exceptions
           Product: Commons
           Version: 2.0 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Collections
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: johal@nakedrobot.com


Is it intentional that SequencedHashMap.indexOf(Object key) throws a 
NullPointerException when the key does not exist in the map?

Shouldn't it return -1 in those situations?

Here is an addition to the TestSequencedHashMap which examplifies the problem

public void testIndexOf() throws Exception {
  Object[] keys = getKeys();
  int expectedSize = keys.length;
  Object[] values = getValues();
  for (int i = 0; i < expectedSize; i++) {
    labRat.put(keys[i], values[i]);
  }
  // test that the index returned are in the same order that they were 
  // placed in the map
  for (int i=0;i<keys.length;i++) {
    assertEquals("indexOf with existing key failed",i,labRat.indexOf(keys[i]));
  }
  // test non existing key..

  assertEquals("test with non-existing key failed",-1,labRat.indexOf
("NonExistingKey"));
}

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message