@ Trivial public static File deleteWithRetry ( File file ) { String methodName = "deleteWithRetry" ; String filePath ; if ( tc . isDebugEnabled ( ) ) { filePath = file . getAbsolutePath ( ) ; Tr . debug ( tc , methodName + ": Recursively delete [ " + filePath + " ]" ) ; } else { filePath = null ; } File firstFailure = delete ( file ) ; if ( firstFailure == null ) { if ( filePath != null ) { Tr . debug ( tc , methodName + ": Successful first delete [ " + filePath + " ]" ) ; } return null ; } if ( filePath != null ) { Tr . debug ( tc , methodName + ": Failed first delete [ " + filePath + " ]: Sleep up to 50 ms and retry" ) ; } // Extract can occur with the server running, and not long after activity // on the previously extracted archives. // // If the first delete attempt failed, try again, up to a limit based on // the expected quiesce time of the zip file cache. File secondFailure = firstFailure ; for ( int tryNo = 0 ; ( secondFailure != null ) && tryNo < RETRY_COUNT ; tryNo ++ ) { try { Thread . sleep ( RETRY_AMOUNT ) ; } catch ( InterruptedException e ) { // FFDC } secondFailure = delete ( file ) ; } if ( secondFailure == null ) { if ( filePath != null ) { Tr . debug ( tc , methodName + ": Successful first delete [ " + filePath + " ]" ) ; } return null ; } else { if ( filePath != null ) { Tr . debug ( tc , methodName + ": Failed second delete [ " + filePath + " ]" ) ; } return secondFailure ; } }
Attempt to recursively delete a target file .