-
Notifications
You must be signed in to change notification settings - Fork 128
Replace deprecated File.toURL() #1847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This pull request changes some projects for the first time in this development cycle.
An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patch
Further information are available in Common Build Issues - Missing version increments. |
with file.toURI().toURL(), where toURL() is called on a java.net.URI instance, which is not deprecated and handles encoding correctly.
@@ -104,7 +104,7 @@ public static void startup(IPath root) { | |||
if (rootURL != null) | |||
return; | |||
try { | |||
rootURL = root.toFile().toURL(); | |||
rootURL = root.toFile().toURI().toURL(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is a place we want to fix because, as also mentioned in #35 (comment), the URL produced here potentially reaches client code outside of the Eclipse platform and they might expect it to be wrongly encoded just as it used to be. So fixing this might be a compatibility problem.
I believe that is also the reason that all the FileLocator
methods where not yet fixed to return properly encoded URLs, but I don't know the exact discussion about this.
Maybe @tjwatson or @merks know if/when/where this was discussed?
In general please be very careful when fixing the URL conversions. The change looks so simple, but it can cause major compatibility problems in unfortunate cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to name a few old bugs, I'm sure there are more:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=126310
https://bugs.eclipse.org/bugs/show_bug.cgi?id=145096
https://bugs.eclipse.org/bugs/show_bug.cgi?id=188685
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HannesWell
How did you identify that this URL might be accessed by client code outside the platform? Was that based on the method being public or something specific in the code? Just trying to understand the scenario better.
Such changes are really scary. You would be shocked how many places expect the url not to be properly encoded. Unless we have extensive tests with paths with spaces, the % character, and non-ascii characters I can pretty much guarantee you that things will go wrong. Don’t do this in isolation. |
java.io.File.toURL()
is deprecated and marked for removal. Replace it withfile.toURI().toURL()
, wheretoURL()
is called on ajava.net.URI
instance, which is not deprecated and handles encoding correctly.