public static void retry ( String action , RunnableThrowsIOException f , RetryPolicy policy ) throws IOException { IOException e = null ; while ( policy . attempt ( ) ) { try { f . run ( ) ; return ; } catch ( IOException ioe ) { e = ioe ; LOG . warn ( "Failed to {} (attempt {}): {}" , action , policy . getAttemptCount ( ) , e . toString ( ) ) ; } } throw e ; }
Retries the given method until it doesn t throw an IO exception or the retry policy expires . If the retry policy expires the last exception generated will be rethrown .