File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
commons-vfs2/src/test/java/org/apache/commons/vfs2 Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 2020import static org .junit .jupiter .api .Assertions .assertNotNull ;
2121import static org .junit .jupiter .api .Assertions .assertTrue ;
2222
23+ import java .io .File ;
2324import java .io .OutputStream ;
2425import java .nio .charset .StandardCharsets ;
2526import java .nio .file .Path ;
@@ -83,19 +84,27 @@ public void tearDown() throws Exception {
8384 final FileObject file = scratchFolder .resolveFile (FILE_NAME );
8485 try {
8586 file .setReadable (true , false );
87+ file .getParent ().setReadable (true , false );
8688 } catch (final FileSystemException e ) {
8789 e .printStackTrace ();
8890 }
8991 try {
9092 file .setWritable (true , false );
93+ file .getParent ().setWritable (true , false );
9194 } catch (final FileSystemException e ) {
9295 e .printStackTrace ();
9396 }
9497 if (!file .delete ()) {
9598 final Path path = file .getPath ();
9699 if ((getFileSystem () instanceof LocalFileSystem )
97100 && (PathUtils .deleteFile (path , StandardDeleteOption .OVERRIDE_READ_ONLY ).getFileCounter ().get () == 0 )) {
98- System .err .println ("Test tear down can't delete " + path );
101+ File f = path .toFile ();
102+ if (!f .delete ()) {
103+ f .deleteOnExit ();
104+ }
105+ if (f .exists ()) {
106+ System .err .println ("Test tear down can't delete " + path );
107+ }
99108 }
100109 }
101110 }
You can’t perform that action at this time.
0 commit comments