-
Notifications
You must be signed in to change notification settings - Fork 219
Extend existence check in URLImageDescriptor when running without OSGi #3106
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 e.g. breaks the scaled image data retrieval in DPIUtil:
|
5c2261f
to
33196c4
Compare
if (FILE_PROTOCOL.equalsIgnoreCase(url.getProtocol())) | ||
return IPath.fromOSString(url.getFile()).toOSString(); | ||
if (FILE_PROTOCOL.equalsIgnoreCase(url.getProtocol())) { | ||
String filePath = IPath.fromOSString(url.getFile()).toOSString(); |
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.
can't we use Path.of(...)
directly.
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 think Path.of(url.toURI()).toString()
is even less readable than IPath.fromOSString(url.getFile()).toOSString()
, in addition to also having to deal with the URISyntaxException.
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.
IPath.fromOSString(url.getFile()).toOSString()
to be honest this looks really bogus, why not simply
String filePath = IPath.fromOSString(url.getFile()).toOSString(); | |
String filePath = url.getFile(); |
but I more was about that below you are using a path anyways so
p = Path.of(url.toURI())
if (Files.exists(Path.of(p))) {
return p.toString();
}
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.
why not simply
As mentioned, you now have to also worry about the potential URISyntaxException and are now depending on something ambiguous as a toString()
method...
But as long as the method behaves consistently, I don't really mind either way.
This extends the check added in cff785d to also consider the case when OSGi isn't running. Otherwise a path to a non-existent file is returned, thus breaking the contract specified in the JavaDoc.
33196c4
to
abd678c
Compare
This extends the check added in cff785d to also consider the case when OSGi isn't running. Otherwise a path to a non-existent file is returned, thus breaking the contract specified in the JavaDoc.