java: fix reconnect failure handling