test/lib/testlibrary/jdk/testlibrary/FileUtils.java

Print this page

        

*** 62,73 **** throws IOException { try { deleteFileWithRetry0(path); } catch (InterruptedException x) { ! // Restore the interrupted status ! Thread.currentThread().interrupt(); } } private static void deleteFileWithRetry0(Path path) throws IOException, InterruptedException --- 62,72 ---- throws IOException { try { deleteFileWithRetry0(path); } catch (InterruptedException x) { ! throw new IOException("Interrupted while deleting.", x); } } private static void deleteFileWithRetry0(Path path) throws IOException, InterruptedException
*** 75,85 **** --- 74,92 ---- int times = 0; IOException ioe = null; while (true) { try { Files.delete(path); + while (true) { + if (Files.notExists(path)) break; + times++; + if (times > MAX_RETRY_DELETE_TIMES) + throw new IOException("File still exists after " + times + " waits."); + Thread.sleep(RETRY_DELETE_MILLIS); + } + break; } catch (NoSuchFileException | DirectoryNotEmptyException x) { throw x; } catch (IOException x) { // Backoff/retry in case another process is accessing the file times++;
*** 129,140 **** try { deleteFileWithRetry0(file); } catch (IOException x) { excs.add(x); } catch (InterruptedException x) { ! // Restore the interrupted status and terminate ! Thread.currentThread().interrupt(); return FileVisitResult.TERMINATE; } return FileVisitResult.CONTINUE; } @Override --- 136,146 ---- try { deleteFileWithRetry0(file); } catch (IOException x) { excs.add(x); } catch (InterruptedException x) { ! excs.add(new IOException("Interrupted while deleting.", x)); return FileVisitResult.TERMINATE; } return FileVisitResult.CONTINUE; } @Override
*** 142,153 **** try { deleteFileWithRetry0(dir); } catch (IOException x) { excs.add(x); } catch (InterruptedException x) { ! // Restore the interrupted status and terminate ! Thread.currentThread().interrupt(); return FileVisitResult.TERMINATE; } return FileVisitResult.CONTINUE; } @Override --- 148,158 ---- try { deleteFileWithRetry0(dir); } catch (IOException x) { excs.add(x); } catch (InterruptedException x) { ! excs.add(new IOException("Interrupted while deleting.", x)); return FileVisitResult.TERMINATE; } return FileVisitResult.CONTINUE; } @Override