The API says basically that this is caused by removing an item while iterating through a fail-fast collection. Not sure what this means, or how I can fix it. Any ideas?
Who dares, wins! (SAS motto)
posted 9 years ago
The documentation for this error isn't very good, unfortunately. The problem is that you are calling remove() directly on the collection while you are iterating that collection. If you want to modify a collection while iterating through it, you should use methods of the iterator, not of the collection. In this case you don't see the Iterator, because it's hidden by the for loop. However to do what you want, you will have to replace the loop with an old-fashioned iteration loop, so that you can see the iterator:
Here the key point is that we're no longer using getPatients().remove(patient) - we're using it.remove(). The Iterator knows how to safely remove objects while iterating. The Collection doesn't.