8158066: SourceDebugExtensionTest fails to rename file
authorgadams
Fri, 18 Jan 2019 05:33:28 -0500
changeset 53382 28b79ca141df
parent 53381 e1da82072c79
child 53383 5dc89efc08f0
8158066: SourceDebugExtensionTest fails to rename file Reviewed-by: dcubed, dholmes
test/hotspot/jtreg/vmTestbase/nsk/share/jdi/sde/InstallSDE.java
test/jdk/ProblemList.txt
test/jdk/com/sun/jdi/sde/InstallSDE.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/sde/InstallSDE.java	Fri Jan 18 09:04:09 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/sde/InstallSDE.java	Fri Jan 18 05:33:28 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2019, 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
@@ -58,12 +58,18 @@
     }
 
     public static void install(File inOutClassFile, File attrFile, boolean verbose) throws IOException {
-        File tmpFile = new File(inOutClassFile.getPath() + "tmp");
+        File tmpFile = new File(inOutClassFile.getPath() + "tmp-out");
+        File tmpInOutClassFile = new File(inOutClassFile.getPath() + "tmp-in");
 
-        new InstallSDE(inOutClassFile, attrFile, tmpFile, verbose);
+        // Workaround delayed file deletes on Windows using a tmp file name
+        if (!inOutClassFile.renameTo(tmpInOutClassFile)) {
+            throw new IOException("inOutClassFile.renameTo(tmpInOutClassFile) failed");
+        }
 
-        if (!inOutClassFile.delete()) {
-            throw new IOException("inOutClassFile.delete() failed");
+        new InstallSDE(tmpInOutClassFile, attrFile, tmpFile, verbose);
+
+        if (!tmpInOutClassFile.delete()) {
+            throw new IOException("tmpInOutClassFile.delete() failed");
         }
         if (!tmpFile.renameTo(inOutClassFile)) {
             throw new IOException("tmpFile.renameTo(inOutClassFile) failed");
--- a/test/jdk/ProblemList.txt	Fri Jan 18 09:04:09 2019 +0100
+++ b/test/jdk/ProblemList.txt	Fri Jan 18 05:33:28 2019 -0500
@@ -838,8 +838,6 @@
 
 com/sun/jdi/RepStep.java                                        8043571 generic-all
 
-com/sun/jdi/sde/SourceDebugExtensionTest.java                   8158066 windows-all
-
 com/sun/jdi/NashornPopFrameTest.java                            8187143 generic-all
 
 ############################################################################
--- a/test/jdk/com/sun/jdi/sde/InstallSDE.java	Fri Jan 18 09:04:09 2019 +0100
+++ b/test/jdk/com/sun/jdi/sde/InstallSDE.java	Fri Jan 18 05:33:28 2019 -0500
@@ -31,10 +31,18 @@
     }
 
     static void install(File inOutClassFile, File attrFile) throws IOException {
-        File tmpFile = new File(inOutClassFile.getPath() + "tmp");
-        new InstallSDE(inOutClassFile, attrFile, tmpFile);
-        if (!inOutClassFile.delete()) {
-            throw new IOException("inOutClassFile.delete() failed");
+        File tmpFile = new File(inOutClassFile.getPath() + "tmp-out");
+        File tmpInOutClassFile = new File(inOutClassFile.getPath() + "tmp-in");
+
+        // Workaround delayed file deletes on Windows using a tmp file name
+        if (!inOutClassFile.renameTo(tmpInOutClassFile)) {
+            throw new IOException("tmp copy of inOutClassFile failed");
+        }
+
+        new InstallSDE(tmpInOutClassFile, attrFile, tmpFile);
+
+        if (!tmpInOutClassFile.delete()) {
+            throw new IOException("tmpInOutClassFile.delete() failed");
         }
         if (!tmpFile.renameTo(inOutClassFile)) {
             throw new IOException("tmpFile.renameTo(inOutClassFile) failed");