You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2003/12/16 01:57:55 UTC

DO NOT REPLY [Bug 25551] New: - NoSuchElementException in ReferenceMap views

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: commons-dev@jakarta.apache.org
        ReportedBy: nullforge@hotmail.com


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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org