#3893 PluginResURLConnection.openStream null return hangs jEdit on Mac OS 10.10

severe bug
closed-fixed
None
5
2015-01-11
2014-11-04
Eric Le Lay
No

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)
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)
calls url.openStream(), doesn't check the return value
returns true if no IOException is raised, returns false otherwise.

PluginResURLConnection.getInputStream
calls connect() to initialize the in field
and returns the in field

PluginResURLConnection.connect
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.

Related

Patches: #539
Plugin Bugs: #1799
Plugin Bugs: #1801
Plugin Bugs: #1802
Commit: [r22920]

Discussion

  • Eric Le Lay

    Eric Le Lay - 2014-11-04
    • summary: PluginResURLConnection.openStream null return crashes jEdit on Mac OS 10.10 --> PluginResURLConnection.openStream null return hangs jEdit on Mac OS 10.10
     
  • Alan Ezust

    Alan Ezust - 2014-11-04

    If I move this to patches, it will change its id and all links to it will break.
    I think you need to open a separate ticket in patches tracker.

     
  • Peter Lynch

    Peter Lynch - 2014-11-05

    nice job!

     
  • Alan Ezust

    Alan Ezust - 2014-11-07

    Please try the latest daily build. Hopefully the issue is fixed now.

     
  • Alan Ezust

    Alan Ezust - 2014-11-09
    • status: open --> closed-fixed
    • assigned_to: Eric Le Lay
     
  • TheoS

    TheoS - 2015-01-11

    Just wanted to say thanks. Not many OSX users, but we do really appreciate jedit very much and all the hard work the team puts in.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks