Skip to content

Commit a2a2958

Browse files
authored
Merge pull request #8917 from eirikbakke/pr-suplogergo
Suppress 'loadImage called with unusual URI: ergoloc:/...' log message
2 parents 1761006 + 6cf31a1 commit a2a2958

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

platform/openide.util.ui/src/org/openide/util/ImageUtilities.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,33 @@ public static final Image loadImage(URI uri) {
238238
} else {
239239
if (!(scheme.equals("file") ||
240240
scheme.equals("jar") && uri.toString().startsWith("jar:file:") ||
241-
scheme.equals("file")))
241+
scheme.equals("file") ||
242+
/* The URL "ergoloc:/org/netbeans/modules/ide/ergonomics/enterprise/org-netbeans-modules-websvc-core-client-resources-ws_client_16.png"
243+
was observed in one frequently occuring case, though in that case no valid Image is
244+
found. See the more specific log statement further below. For now we just handle
245+
these URLs the way they were always handled, with Toolkit.createImage. */
246+
scheme.equals("ergoloc")))
242247
{
243248
LOGGER.log(Level.WARNING, "loadImage(URI) called with unusual URI: {0}", uri);
244249
}
245250
try {
246251
/* Observed to return an image with size (-1, -1) if URL points to a non-existent
247252
file (after ensureLoaded(Image) is called). */
248-
return Toolkit.getDefaultToolkit().createImage(uri.toURL());
253+
Image ret = Toolkit.getDefaultToolkit().createImage(uri.toURL());
254+
255+
if (ret != null && scheme.equals("ergoloc") &&
256+
ret.getWidth(null) > 0 &&
257+
ret.getHeight(null) > 0)
258+
{
259+
/* If this case ever occurs, and we decide we need to support an SVG version of
260+
the icon in question, then we might need to handle "ergoloc" in the same way as we
261+
handle "nbresloc" earlier. See o.n.modules.ide.ergonomics.fod.FoDURLStreamHandler,
262+
which simply replaces ergoloc to nbresloc for ergoloc URLs that do not end with
263+
".html". It might still be necessary to open the original URL first to trigger
264+
whatever module loading magic the ergonomics module is supposed to cause. */
265+
LOGGER.log(Level.INFO, "loadImage(URI) got valid image from ergoloc URI: {0}", uri);
266+
}
267+
return ret;
249268
} catch (MalformedURLException e) {
250269
LOGGER.log(Level.WARNING, "Malformed URL passed to loadImage(URI)", e);
251270
return null;

0 commit comments

Comments
 (0)