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
This commit is contained in:
Alpar Torok 2019-08-06 14:31:28 +03:00
parent a453cd489e
commit b3076adae6
1 changed files with 8 additions and 2 deletions

View File

@ -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);
}