selectedKeys is touched by multiple threads, a foreach loop in java is not thread safe as it modifies the set while it loops, i believe instead of using the iterator methods it's using the poll() underneath the covers and can cause "arbitrary, nondeterministic" behavior and/or ConcurrentModificationExceptions.   The iterator is the appropriate way to loop through a selectedKeys set in this scenario.   I believe that this is an important change based on best practices, and that it only presents problems under high load and thus is very difficult to chase down.