private < T > T executeHttpCallWithRetry ( HttpCall < T > call , int runCount ) { try { return call . execute ( ) ; } catch ( PackageManagerHttpActionException ex ) { // retry again if configured so... if ( runCount < props . getRetryCount ( ) ) { log . info ( "ERROR: " + ex . getMessage ( ) ) ; log . debug ( "HTTP call failed." , ex ) ; log . info ( "---------------" ) ; StringBuilder msg = new StringBuilder ( ) ; msg . append ( "HTTP call failed, try again (" + ( runCount + 1 ) + "/" + props . getRetryCount ( ) + ")" ) ; if ( props . getRetryDelaySec ( ) > 0 ) { msg . append ( " after " + props . getRetryDelaySec ( ) + " second(s)" ) ; } msg . append ( "..." ) ; log . info ( msg ) ; if ( props . getRetryDelaySec ( ) > 0 ) { try { Thread . sleep ( props . getRetryDelaySec ( ) * DateUtils . MILLIS_PER_SECOND ) ; } catch ( InterruptedException ex1 ) { // ignore } } return executeHttpCallWithRetry ( call , runCount + 1 ) ; } else { throw ex ; } } }
Execute HTTP call with automatic retry as configured for the MOJO .