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=25551>.
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=25551

NoSuchElementException in ReferenceMap views

           Summary: NoSuchElementException in ReferenceMap views
           Product: Commons
           Version: Nightly Builds
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Collections
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The keySet() and values() views for the 
org.apache.commons.collections.map.ReferenceMap class will throw a 
NoSuchElementException in their toArray(Object[]) methods if any keys or values 
have been reclaimed by the garbage collector and purge() has not been invoked.  
The toArray(Object[]) implementation inherited from 
java.util.AbstractCollection uses size()-based iteration rather than hasNext()-
based iteration.  This is inappropriate because the size of the map can change 
during iteration.  The problem is exacerbated by the fact that neither the 
KeySet nor Values classes purge stale elements from the list in their size() 
methods.

The attached test case reliably reproduces this exception with Sun's 1.3.1_07 
and 1.4.2 Win2K Hotspot VMs.

The attached diff is a proposed fix for this issue.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to