Maybe a boolean like "fatal" and then the while condition could be: (!fatal && ++tries < 5)?

This may just be subjective (i.e. my suggestions might make it seem more complicated). I was confused because there were multiple ways to exit out of the loop (2 breaks and 2 throws plus any uncaught exception), and I always get nervous when I see while(true), since in the future, someone could make a naive change that leads to an infinite retry.