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 13
13
import org .apache .logging .log4j .Logger ;
14
14
15
15
import java .nio .file .Files ;
16
- import java .nio .file .Path ;
17
16
import java .nio .file .Paths ;
18
17
import java .util .Arrays ;
19
18
import java .util .Collections ;
20
19
import java .util .List ;
21
- import java .util .function .Consumer ;
22
20
23
21
import static org .elasticsearch .packaging .test .PackagingTestCase .getRootTempDir ;
24
22
import static org .elasticsearch .packaging .util .FileUtils .lsGlob ;
@@ -75,11 +73,9 @@ public static void cleanEverything() throws Exception {
75
73
// when we run es as a role user on windows, add the equivalent here
76
74
// delete files that may still exist
77
75
78
- lsGlob (getRootTempDir (), "elasticsearch*" ).forEach (Platforms . WINDOWS ? FileUtils :: rmWithRetries : FileUtils ::rm );
76
+ lsGlob (getRootTempDir (), "elasticsearch*" ).forEach (FileUtils ::rm );
79
77
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 );
83
79
}
84
80
85
81
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) {
75
75
}
76
76
77
77
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
+ }
82
86
}
83
87
}
84
88
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 ) {
86
91
int tries = 10 ;
87
- Exception exception = null ;
92
+ IOException exception = null ;
88
93
while (tries -- > 0 ) {
89
94
try {
90
95
IOUtils .rm (paths );
@@ -103,7 +108,7 @@ public static void rmWithRetries(Path... paths) {
103
108
return ;
104
109
}
105
110
}
106
- throw new RuntimeException (exception );
111
+ throw new UncheckedIOException (exception );
107
112
}
108
113
109
114
public static Path mktempDir (Path path ) {
You can’t perform that action at this time.
0 commit comments