[ 
https://issues.apache.org/jira/browse/COLLECTIONS-411?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13692255#comment-13692255
 ] 

Sebb commented on COLLECTIONS-411:
----------------------------------

Looks like a bug to me, because the size() is 2 just before the putAll().

The problem is that the code assumes that the put method will only return null 
if the key was not replaced; however that is only true if the original value 
was not null. For maps that allow null, the return value of put cannot be used 
to determine if the key was replaced.
                
> Exception in ListOrderedMap.putAll()
> ------------------------------------
>
>                 Key: COLLECTIONS-411
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-411
>             Project: Commons Collections
>          Issue Type: Bug
>         Environment: java 1.6.0_24
> Ubuntu 11.10
>            Reporter: Adrian Nistor
>             Fix For: 4.0
>
>         Attachments: Test.java
>
>
> Hi,
> I am encountering an IndexOutOfBoundsException in
> ListOrderedMap.putAll(int index, Map<? extends K, ? extends V> map).
> It appears in revision 1351903 (20 June 2012).  I have attached a test
> that exposes this problem.
> To run the test, just do:
> $ java Test
> The output is:
> ......................................................................
> Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 5, 
> Size: 4
>         at java.util.ArrayList.add(ArrayList.java:367)
>         at 
> org.apache.commons.collections.map.ListOrderedMap.put(ListOrderedMap.java:437)
>         at 
> org.apache.commons.collections.map.ListOrderedMap.putAll(ListOrderedMap.java:245)
>         at Test.main(Test.java:19)
> ......................................................................
> The documentation does not specify anything like this.  Is this a bug,
> or should the documentation just be updated?  If the former, is there
> a patch for it?
> Thanks,
> Adrian

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to