commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections MultiHashMap.java
Date Tue, 04 Jan 2005 00:13:25 GMT
scolebourne    2005/01/03 16:13:25

  Modified:    collections RELEASE-NOTES.html
               collections/src/test/org/apache/commons/collections
                        TestMultiHashMap.java
               collections/src/java/org/apache/commons/collections
                        MultiHashMap.java
  Log:
  Fix MultiHashMap to return null when nothing removed
  bug 32366, reported by Tad Marko
  
  Revision  Changes    Path
  1.76      +1 -0      jakarta-commons/collections/RELEASE-NOTES.html
  
  Index: RELEASE-NOTES.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/RELEASE-NOTES.html,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- RELEASE-NOTES.html	4 Jan 2005 00:01:31 -0000	1.75
  +++ RELEASE-NOTES.html	4 Jan 2005 00:13:25 -0000	1.76
  @@ -52,6 +52,7 @@
   <ul>
   <li>FastArrayList - Fix iterators and views to work better in multithreaded environments</li>
   <li>BoundedFifoBuffer/CircularFifoBuffer - Fix serialization to work in case where
buffer serialized when full [31433]</li>
  +<li>MultiHashMap.remove(key, item) - Was returning the item even when nothing was
removed [32366]</li>
   </ul>
   
   <center><h3>JAVADOC</h3></center>
  
  
  
  1.21      +15 -2     jakarta-commons/collections/src/test/org/apache/commons/collections/TestMultiHashMap.java
  
  Index: TestMultiHashMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestMultiHashMap.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- TestMultiHashMap.java	9 Jun 2004 22:11:54 -0000	1.20
  +++ TestMultiHashMap.java	4 Jan 2005 00:13:25 -0000	1.21
  @@ -1,5 +1,5 @@
   /*
  - *  Copyright 2001-2004 The Apache Software Foundation
  + *  Copyright 2001-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -415,6 +415,19 @@
           assertEquals(3, map.size());
           assertEquals(2, newMap.size());
           assertEquals(1, newColl.size());
  +    }
  +
  +    public void testRemove_KeyItem() {
  +        MultiHashMap map = new MultiHashMap();
  +        map.put("A", "AA");
  +        map.put("A", "AB");
  +        map.put("A", "AC");
  +        assertEquals(null, map.remove("C", "CA"));
  +        assertEquals(null, map.remove("A", "AD"));
  +        assertEquals("AC", map.remove("A", "AC"));
  +        assertEquals("AB", map.remove("A", "AB"));
  +        assertEquals("AA", map.remove("A", "AA"));
  +        assertEquals(new MultiHashMap(), map);
       }
   
   }
  
  
  
  1.21      +6 -4      jakarta-commons/collections/src/java/org/apache/commons/collections/MultiHashMap.java
  
  Index: MultiHashMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/MultiHashMap.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- MultiHashMap.java	9 Jun 2004 22:11:54 -0000	1.20
  +++ MultiHashMap.java	4 Jan 2005 00:13:25 -0000	1.21
  @@ -1,5 +1,5 @@
   /*
  - *  Copyright 2001-2004 The Apache Software Foundation
  + *  Copyright 2001-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -314,8 +314,10 @@
           if (valuesForKey == null) {
               return null;
           }
  -        valuesForKey.remove(item);
  -
  +        boolean removed = valuesForKey.remove(item);
  +        if (removed == false) {
  +            return null;
  +        }
           // remove the list if it is now empty
           // (saves space, and allows equals to work)
           if (valuesForKey.isEmpty()){
  
  
  

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


Mime
View raw message