[RFC][icedtea-web] Fix NPE thrown when applets in the plugin fail.
ddadacha at redhat.com
Mon Mar 12 13:50:19 PDT 2012
On 29/02/12 04:02 PM, Danesh Dadachanji wrote:
> Any applet run by the plugin that throws an exception while loading
> (before init() is called) will output an NPE. This is because we have
> sent 3 events to the queue when the plugin is setup, APPLET_LOAD,
> APPLET_INIT and APPLET_START. This was causing problems when
> AppletInstance was not being set, and specifically when AppletInstance's
> Applet var was left as null.
> AppletPanel's run thread continues to the next event, APPLET_INIT even
> if in APPLET_LOAD, the applet var was not set (exception occurred in the
> constructor of the applet, Launcher#createApplet() crashed etc). Then,
> the applet var is set to null so when it is referenced in APPLET_INIT's
> execution, the NPE is thrown.
> There is no way of removing an event from the queue in our given
> situation. I tried finding a method that would do this so that I could
> empty the queue if either AppletInstance or Applet vars were null but I
> could not find one. The queue is also private to AppletPanel and since
> we cannot modify that, the only resolution I saw was to conditionally
> add the events to the queue later on down the line.
> The changes I've made in the attached patch simply remove sending the
> init and start event when initializing the panel and send these signals
> once NetxPanel confirms a non-null applet. NetxPanel's runLoader is only
> executed in consequence to APPLET_LOAD so I believe it is safe to add
> these events here. The patch also sends an APPLET_DISPOSE event if it
> fails to run, which is just cleanup.
> Reproducer is somewhat in the works (depending on limitations of running
> it in a browser). For your testing, just make an applet that throws
> something and you should see an NPE in NetxPanel and an NPE in AppletPanel.
> +2012-02-29 Danesh Dadachanji <ddadacha at redhat.com>
> + Fix NPE thrown when applets run by the plugin fail to initialize.
> + * netx/net/sourceforge/jnlp/NetxPanel.java
> + (runLoader): Check for null applet instance, if it is then send a dispose
> + event. If it is not, continue as before. If the applet is not null, send
> + an init and start event to the AppletPanel queue.
> + * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
> + (initEventQueue): Removed sending of APPLET_INIT and APPLET_START events.
> I'd like to push this to HEAD, are there any comments?
After thinking about this and discussing it some more, I think this
patch isn't needed.
While the NPE occurs, it does not affect any subsequently run applets
and somewhat gracefully hangs when such an applet runs. The JVM as a
whole isn't affected so I think it would be safer to stick with what we
The plugin does stall until the browser decides to kill of the JS. This
takes irritatingly long so I have filed a bug for it. That is a
separate issue as it occurs regardless of this patch.
More information about the distro-pkg-dev