I have some code which connects to a URL to download a file, and then performs some processing on it. However, sometimes I am receiving the error java.net.SocketException:
java.net.SocketException:
AOP and Java annotations should help. I would recommend a read-made mechanism from jcabi-aspects (I'm a developer):
@RetryOnFailure(attempts = 3, delay = 5) public String load(URL url) { return url.openConnection().getContent(); }
You may also try RetryFunc from Cactoos.