Move automatic recovery to the Java client

Fixes #58 and, by proxy, #54.