Merge in fix for Glassfish-21175

Jaromir,

Nice spot, will fix as appropriate in this class so as to place in a while(condition) if needed. Will firstly check if this is not been called in a loop from the caller before doing so.