What should I do with BackOffInterruptedException in Spring's RetryTemplate?

2.1k views Asked by At

I'm going through automatic error reports from my desktop application, and I have this exception which I'm not sure how to handle:

java.lang.InterruptedException: sleep interrupted
    at java.lang.Thread.sleep(Thread.java)
    at org.springframework.retry.backoff.ThreadWaitSleeper.sleep(ThreadWaitSleeper.java:30)
    at org.springframework.retry.backoff.ExponentialBackOffPolicy.backOff(ExponentialBackOffPolicy.java:181)
    at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:306)
    at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:164)

org.springframework.retry.backoff.BackOffInterruptedException: Thread interrupted while sleeping; nested exception is java.lang.InterruptedException: sleep interrupted
    at org.springframework.retry.backoff.ExponentialBackOffPolicy.backOff(ExponentialBackOffPolicy.java:184)
    at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:306)
    at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:164)

The code uses Spring's RetryTemplate with an ExponentialBackOffPolicy. I understand the sleeping thread got interrupted, but I don't know why, and thus, I don't know what I should do about it. If the application was exiting, then, silently swallowing that exception would be appropriate. If something stopped working and need restarting, then, I should do that; but I was hopping that RetryTemplate would already do that for me in all situations where it makes sense. I don't want to retry around RetryTemplate.

0

There are 0 answers