Put some checks in ItemWriterRetryPolicy to try and detect hash codes that are inconsistent (it would be better to move that responsibility to the RetryContextCache, since the implementation might not be based on hash codes - leave that for future release).
Also the MapRetryContextCache now has a maximum capacity, and throws an exception if it reaches that. This prevents the kind of basic error from the forum post where the hashCode of items is not consistent between calls to ItemReader.read(). The default capacity is 4096, so you have to wait quite a while before it fails by default, but at least it isn't an infinite loop. The capacity is for the whole cache, but it would be quite unusual for the limit to be reached in normal circs because failed items are removed when they are recovered.
Also had to make sure RetryException was fatal for the ItemHandler in the retry step factory bean (through the step-level exception handler).