Steps to reproduce
------------------
- install jEdit daily 2014-11-03_05-01-41 + Console plugin
- open Console dockable
- you get this stack trace on stderr:
````
14:01:44 [Image Fetcher 3] [error] Image Fetcher 3: Uncaught error
fetching image:
14:01:44 [Image Fetcher 3] [error] Image Fetcher 3:
java.lang.NullPointerException
14:01:44 [Image Fetcher 3] [error] Image Fetcher 3: at
sun.awt.image.InputStreamImageSource.getDecoder(InputStreamImageSource.java:214)
14:01:44 [Image Fetcher 3] [error] Image Fetcher 3: at
sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:159)
14:01:44 [Image Fetcher 3] [error] Image Fetcher 3: at
sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:263)
14:01:44 [Image Fetcher 3] [error] Image Fetcher 3: at
sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:205)
14:01:44 [Image Fetcher 3] [error] Image Fetcher 3: at
sun.awt.image.ImageFetcher.run(ImageFetcher.java:169)
````
- jEdit is frozen
Cause
-----
java 8 on Mac OS X (10.10) tries to load bigger images for High DPI (retina) screens
(or not: I don't have a retina screen but I'm hit by the bug).
Following a call to new ImageIcon(URL), LWCToolkit.getImage(URL) automatically tries
to load an high-dpi version of the icon and falls back to normal if it's not found.
high-dpi version of icon.png is icon@2x.png.
See https://bugs.openjdk.java.net/browse/JDK-8011059
This is why it's only visible running java 8 on the mac, not on linux.
What happens
------------
[LWCToolkit.getImage(URL)](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/67b22a82345b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java#l555)
modifies the name of the image to append @2x
(jeditresource:/org/gjt/sp/jedit/icons/themes/tango/22x22/actions/application-run-again.png
becomes
jeditresource:/org/gjt/sp/jedit/icons/themes/tango/22x22/actions/application-run-again@2x.png)
It then calls SunToolkit.imageExists() to check for existence of this
image.
If it returns false, it carries on with the default image.
If it returns true, it uses the @2x image
[SunToolkit.imageExists(URL)](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/67b22a82345b/src/share/classes/sun/awt/SunToolkit.java#l902)
calls url.openStream(), doesn't check the return value
returns true if no IOException is raised, returns false otherwise.
[PluginResURLConnection.getInputStream](http://sourceforge.net/p/jedit/svn/HEAD/tree/jEdit/trunk/org/gjt/sp/jedit/proto/jeditresource/PluginResURLConnection.java#l119)
calls connect() to initialize the in field
and returns the in field
[PluginResURLConnection.connect](http://sourceforge.net/p/jedit/svn/HEAD/tree/jEdit/trunk/org/gjt/sp/jedit/proto/jeditresource/PluginResURLConnection.java)
When the icon is from jedit.jar, it throws an IOException if in is null
(line 109),
resulting in LWCToolkit to switch to the normal image, which is loaded.
When the icon is from a plugin, it doesn't throw an IOException as long
as the plugin is found, even if the resource is not found (input stream is null).
Then LWCToolkit carries on with the non-existent icon@2x.png and hits a NullPointerException
later when it tries to read from the InputStream.
Fix:
- checking for null InputStream in PluginResURLConnection.connect() and
throwing an exception in this case fixes the issue (the dockable opens).
The java api doc is not specific about what kind of issue should trigger an
IOException but SunToolkit expects an IOException if resource is not found.
This conflict with [r22920]: I added a test for null InputStream; should try/catch
there also.
| Submitted | kerik-sf - 2014-11-04 19:39:38.554000 | Assigned | |
|---|---|---|---|
| Priority | 5 | Labels | |
| Status | open | Group | severe bug |
| Resolution | None |
| 2014-11-04 19:39:57.407000 kerik-sf |
- **summary**: PluginResURLConnection.openStream null return crashes jEdit on Mac
OS 10.10 --> PluginResURLConnection.openStream null return hangs jEdit on Mac OS 10.10 |
|---|---|
| 2014-11-04 20:05:57.123000 kerik-sf |
here is a patch fixing it. 0001-fix-3893-PluginResURLConnection.openStream-null-retu.patch (5.2Kio) |
| 2014-11-04 20:15:10.235000 ezust |
If I move this to patches, it will change its id and all links to it will break.
|
| 2014-11-04 20:24:37.289000 kerik-sf |
done: [patches:#539] |
| 2014-11-05 18:48:27.478000 peterlynch |
nice job! |
| 2014-11-07 16:09:47.484000 ezust |
Please try the latest daily build. Hopefully the issue is fixed now.
|