Browse Source

Fix reaper build failures on Windows (#45205)

We configure the service ID as the node's toString but this containes
characters that Windows doesn't like.
This PR fixes it by allowing only alphanumeric characters
Alpar Torok 6 years ago
parent
commit
c4bab8a503

+ 8 - 2
buildSrc/src/main/java/org/elasticsearch/gradle/ReaperService.java

@@ -63,15 +63,21 @@ public class ReaperService {
         ensureReaperStarted();
 
         try {
-            Files.writeString(inputDir.resolve(serviceId + ".cmd"), String.join(" ", command));
+            Files.writeString(getCmdFile(serviceId), String.join(" ", command));
         } catch (IOException e) {
             throw new UncheckedIOException(e);
         }
     }
 
+    private Path getCmdFile(String serviceId) {
+        return inputDir.resolve(
+            serviceId.replaceAll("[^a-zA-Z0-9]","-") + ".cmd"
+        );
+    }
+
     public void unregister(String serviceId) {
         try {
-            Files.deleteIfExists(inputDir.resolve(serviceId + ".cmd"));
+            Files.deleteIfExists(getCmdFile(serviceId));
         } catch (IOException e) {
             throw new UncheckedIOException(e);
         }