Executes an operation once and -- when it fails with an exception -- retries it several times until no exception is thrown or the specified number of retries is exceeded.
Executes an operation once and -- when it fails with an exception -- retries it several times until no exception is thrown or the specified number of retries is exceeded.
maximum number of retries
milliseconds to wait between retries (non-negative value, defaults to 0)
operation to be executed
the result of the last try of the operation in case of success
Exception
whatever is thrown by the last try of the operation in case
of no success
IllegalArgumentException
if the value of delayMs
is negative
The maximum number of executions is equal to the maximum number of retries plus 1.
Provides using a resource and ensures closing it even in case of an exception.
Provides using a resource and ensures closing it even in case of an exception.
From the book Beginning Scala by David Pollak.
a closable resource of structural type {def close(): Unit}
maps the resource to a result
the result