28 June 2010

Bug in ListCookieHandler Java class

The ListCookieHandler class is referenced on many web sites and the source code is provided on a subset of those (one instance at java2s). It's credited as coming from the book Java 6 Platform Revealed, however I couldn't find the implementation within that book searching via either Amazon or Google Books. Either way, there's a couple of errors in all of the implementations I've seen where two for-each loops are used with remove methods called on the collection within the loop. This is not allowed for obvious reasons and results in a ConcurrentModificationException being thrown.

[ posted by sstrader on 28 June 2010 at 12:25:24 PM in Programming ]