{"thread":{"id":"16005","subject":"[JGIT PATCH 1/3] Fix retrieval of test resources for paths containing spaces","startedAt":"2008-10-22T08:32:18Z","lastAt":"2008-10-22T08:32:18Z","messageCount":1,"participants":["Jonas Fonseca"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"93662","messageId":"20081022083217.GA17940@diku.dk","threadId":"16005","inReplyTo":null,"subject":"[JGIT PATCH 1/3] Fix retrieval of test resources for paths containing spaces","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2008-10-22T08:32:18Z","receivedAt":"2008-10-22T08:32:18Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"The use of URL.getPath() can be problematic when the repository path\ncontains spaces since they get encoded as %20, which will lead to a \"No\nsuch file\" error when resolving to a local file. The fix first tries to\nconvert the resource URL to a URI (added in Java 1.5), which is then\nused to construct the File instance. As a fallback use the old behavior\nif a URISyntaxException is thrown.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n .../tst/org/spearce/jgit/util/JGitTestUtil.java    |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\nindex bf2471d..eee0c14 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\n@@ -38,6 +38,7 @@\n package org.spearce.jgit.util;\n \n import java.io.File;\n+import java.net.URISyntaxException;\n import java.net.URL;\n \n public abstract class JGitTestUtil {\n@@ -57,7 +58,11 @@ public static File getTestResourceFile(final String fileName) {\n \t\t\t// loaded previously\n \t\t\treturn new File(\"tst\", fileName);\n \t\t}\n-\t\treturn new File(url.getPath());\n+\t\ttry {\n+\t\t\treturn new File(url.toURI());\n+\t\t} catch(URISyntaxException e) {\n+\t\t\treturn new File(url.getPath());\n+\t\t}\n \t}\n \n \tprivate static ClassLoader cl() {\n-- \n1.6.0.2.1166.g8d97a.dirty\n\n-- \nJonas Fonseca\n"}]}