From 2eedb12cdbb3e48bb61f44ca1313a85add14aa88 Mon Sep 17 00:00:00 2001 From: Michael Tsang Date: Wed, 18 Dec 2024 10:53:22 +0000 Subject: [PATCH] fix test failure when building OTP in a path with special characters. https://stackoverflow.com/a/13470643 fixes #6337 --- .../org/opentripplanner/test/support/ResourceLoader.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/application/src/test/java/org/opentripplanner/test/support/ResourceLoader.java b/application/src/test/java/org/opentripplanner/test/support/ResourceLoader.java index 5670a49fab7..e22d47b7f94 100644 --- a/application/src/test/java/org/opentripplanner/test/support/ResourceLoader.java +++ b/application/src/test/java/org/opentripplanner/test/support/ResourceLoader.java @@ -8,6 +8,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; +import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.List; @@ -46,7 +47,12 @@ public static ResourceLoader of(Object object) { */ public File file(String path) { URL resource = url(path); - var file = new File(resource.getFile()); + File file; + try { + file = new File(new URI(resource.toString())); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } assertTrue( file.exists(), "File '%s' not found on file system.".formatted(file.getAbsolutePath())