File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed
qa/packaging/src/test/java/org/elasticsearch/packaging/util Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change 1313import org .apache .logging .log4j .Logger ;
1414
1515import java .nio .file .Files ;
16- import java .nio .file .Path ;
1716import java .nio .file .Paths ;
1817import java .util .Arrays ;
1918import java .util .Collections ;
2019import java .util .List ;
21- import java .util .function .Consumer ;
2220
2321import static org .elasticsearch .packaging .test .PackagingTestCase .getRootTempDir ;
2422import static org .elasticsearch .packaging .util .FileUtils .lsGlob ;
@@ -75,11 +73,9 @@ public static void cleanEverything() throws Exception {
7573 // when we run es as a role user on windows, add the equivalent here
7674 // delete files that may still exist
7775
78- lsGlob (getRootTempDir (), "elasticsearch*" ).forEach (Platforms . WINDOWS ? FileUtils :: rmWithRetries : FileUtils ::rm );
76+ lsGlob (getRootTempDir (), "elasticsearch*" ).forEach (FileUtils ::rm );
7977 final List <String > filesToDelete = Platforms .WINDOWS ? ELASTICSEARCH_FILES_WINDOWS : ELASTICSEARCH_FILES_LINUX ;
80- // windows needs leniency due to asinine releasing of file locking async from a process exiting
81- Consumer <? super Path > rm = Platforms .WINDOWS ? FileUtils ::rmWithRetries : FileUtils ::rm ;
82- filesToDelete .stream ().map (Paths ::get ).filter (Files ::exists ).forEach (rm );
78+ filesToDelete .stream ().map (Paths ::get ).filter (Files ::exists ).forEach (FileUtils ::rm );
8379 }
8480
8581 private static void purgePackagesLinux () {
Original file line number Diff line number Diff line change @@ -75,16 +75,21 @@ public static List<Path> lsGlob(Path directory, String glob) {
7575 }
7676
7777 public static void rm (Path ... paths ) {
78- try {
79- IOUtils .rm (paths );
80- } catch (IOException e ) {
81- throw new RuntimeException (e );
78+ if (Platforms .WINDOWS ) {
79+ rmWithRetries (paths );
80+ } else {
81+ try {
82+ IOUtils .rm (paths );
83+ } catch (IOException e ) {
84+ throw new UncheckedIOException (e );
85+ }
8286 }
8387 }
8488
85- public static void rmWithRetries (Path ... paths ) {
89+ // windows needs leniency due to asinine releasing of file locking async from a process exiting
90+ private static void rmWithRetries (Path ... paths ) {
8691 int tries = 10 ;
87- Exception exception = null ;
92+ IOException exception = null ;
8893 while (tries -- > 0 ) {
8994 try {
9095 IOUtils .rm (paths );
@@ -103,7 +108,7 @@ public static void rmWithRetries(Path... paths) {
103108 return ;
104109 }
105110 }
106- throw new RuntimeException (exception );
111+ throw new UncheckedIOException (exception );
107112 }
108113
109114 public static Path mktempDir (Path path ) {
You can’t perform that action at this time.
0 commit comments