Opened 18 years ago
Closed 17 years ago
#202 closed defect (fixed)
Wrong URL sometimes generated on Windows
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | Core | Version: | tested |
Keywords: | Cc: |
Description
Sometimes the wrong url is generated on Windows, making it impossible to read the plugin jar. The correct way to generate a URL from a File in Java is file.toURI().toURL() . (file.toURL() by itself has bugs that the Java developers felt they couldn't fix without breaking backwards compatibility).
Attachments (1)
Change History (5)
by , 18 years ago
Attachment: | josmpatch.txt added |
---|
comment:1 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 18 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
patch doesn't work. Please describe when wrong URLs are generated and what these URLs are.
comment:3 by , 18 years ago
Sorry this is getting to you late. I typed in a long response like a week ago, but I guess I must not have submitted it correctly. I went to check on this bug today and noticed that the reply wasn't there, so here it is again.
My JOSM plugin directory is on a Windows network drive. The location is
server\docs$\username\Application Data\JOSM\plugins\.
new URL(getURLString(file.getAbsolutePath())) returns
file:/server/docs$/username/Application Data/JOSM/plugins/annotation-tester.jar
That url produces a FileNotFoundException.
Replacing that code with file.toURI().toURL() yeilds
file://server/docs$/username/Application%20Data/JOSM/plugins/annotation-tester.jar
I don't know if it's the space or the missing slash after the colon that causes the problem, but it could well be both. According to the Javadocs for File, file.toURI().toURL() is the recommended way to turn a file into a URL.
patch against latest svn that fixes the problem