I want to retry something that might time out, an HTTP request maybe. So I tried this:
(diehard/with-retry {:retry-on TimeoutExceededException
:max-retries 1}
(diehard/with-timeout {:timeout-ms 100}
;; Something that might time out
(Thread/sleep 200)))
This results in a NullPointerException:
Execution error (NullPointerException) at user/eval173014 (user.clj:301).
Cannot throw exception because the return value of "java.lang.Throwable.getCause()" is null
My guess is it happens because the throwed TimeoutExceededException does not have a cause:
But I'm wondering if there's a better intended way to do this, or if there maybe should be a check around the .getCause in with-retry that would throw the original exception if the cause was nil?
I want to retry something that might time out, an HTTP request maybe. So I tried this:
This results in a NullPointerException:
My guess is it happens because the throwed TimeoutExceededException does not have a cause:
Yet
with-retry
assumes that aFailsafeException
always has a cause: https://github.com/sunng87/diehard/blob/master/src/diehard/core.clj#L365I've worked around this by throwing a new exception that has the TimeoutExceededException as cause:
But I'm wondering if there's a better intended way to do this, or if there maybe should be a check around the
.getCause
inwith-retry
that would throw the original exception if the cause was nil?