Skip to content

Commit 83d32d2

Browse files
committed
Extend existence check in URLImageDescriptor when running without OSGi
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.
1 parent 0e4942b commit 83d32d2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

bundles/org.eclipse.jface/src/org/eclipse/jface/resource/URLImageDescriptor.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,12 @@ private static String getxPath(String name, int zoom) {
249249
private static String getFilePath(URL url, boolean logIOException) {
250250
try {
251251
if (!InternalPolicy.OSGI_AVAILABLE) {
252-
if (FILE_PROTOCOL.equalsIgnoreCase(url.getProtocol()))
253-
return IPath.fromOSString(url.getFile()).toOSString();
252+
if (FILE_PROTOCOL.equalsIgnoreCase(url.getProtocol())) {
253+
String filePath = IPath.fromOSString(url.getFile()).toOSString();
254+
if (Files.exists(Path.of(filePath))) {
255+
return filePath;
256+
}
257+
}
254258
return null;
255259
}
256260
url = resolvePathVariables(url);

0 commit comments

Comments
 (0)