test/jdk/sun/security/tools/keytool/KeyToolTest.java
changeset 49882 a02abc7e5536
parent 47216 71c04702a3d5
child 51944 28085dba5d9a
--- a/test/jdk/sun/security/tools/keytool/KeyToolTest.java	Tue Apr 24 21:40:10 2018 -0700
+++ b/test/jdk/sun/security/tools/keytool/KeyToolTest.java	Wed Apr 25 12:29:48 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,6 +65,7 @@
 import java.security.NoSuchAlgorithmException;
 import java.util.*;
 import java.security.cert.X509Certificate;
+import jdk.test.lib.util.FileUtils;
 import sun.security.util.ObjectIdentifier;
 
 public class KeyToolTest {
@@ -118,9 +119,10 @@
         if (debug) {
             System.err.println("Removing " + filename);
         }
-        new File(filename).delete();
-        if (new File(filename).exists()) {
-            throw new RuntimeException("Error deleting " + filename);
+        try{
+            FileUtils.deleteFileIfExistsWithRetry(Paths.get(filename));
+        }catch(IOException e) {
+            throw new RuntimeException("Error deleting " + filename, e);
         }
     }