According to the java api
NoSuchElementException
Thrown by the nextElement method of an
Enumeration to indicate that there are
no more elements in the enumeration.
I tested the following code locally
ConcurrentHashMap<String, String> t = new ConcurrentHashMap<String, String>();
List<String> al = new ArrayList<String>(t.values());
Collections.sort(al);
System.out.println("no bugs");
(with Eclipse jdk 1.5) I get the expected output. I also ran my local test after putting some key-value pairs into the ConcurrentHashMap and had no problems. Based on my successes, it would seem that one (or both) of the following is causing the discrepancy between our results.
A) We are using different class implementations (I use java.util.concurrent.ConcurrentHashMap, java.util.List, java.util.ArrayList from jdk 1.5)
B) You are modifying the contents of ArrayList or ConcurrentHashMap WHILE an iterator is iterating through the contents of said object. Does the exception occur while running the sort? My best guess is another thread is messing with your ArrayList (since ConcurentHashMap is supposed to be thread safe) while you are sorting.