JDK-6648922 : Exceptions in GrayBoxPainter can cause applet to not load
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u10
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-01-10
  • Updated: 2010-09-17
  • Resolved: 2008-01-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u10 b11Fixed 7Fixed
Description
The GrayBoxPainter in the plug-in is notorious for the exceptions it prints to the Java Console. The root cause of these exceptions is the fact that this class is generally used in a thread-unsafe manner, which is at least partially unavoidable (at least, not without large restructuring of the code) due to how the download progress callbacks work. Here, however, is a stack trace from the new Java Plug-In where such an error causes an applet to not load properly:

java.lang.NullPointerException: component argument pData
	at sun.java2d.windows.GDIRenderer.doFillRect(Native Method)
	at sun.java2d.windows.GDIRenderer.fillRect(GDIRenderer.java:129)
	at sun.java2d.pipe.ValidatePipe.fillRect(ValidatePipe.java:58)
	at sun.java2d.SunGraphics2D.fillRect(SunGraphics2D.java:2274)
	at sun.plugin.util.GrayBoxPanel.paint(GrayBoxPanel.java:133)
	at sun.plugin.util.GrayBoxPainter.paintGrayBox(GrayBoxPainter.java:363)
	at sun.plugin.util.GrayBoxPainter.repaintGrayBox(GrayBoxPainter.java:313)
	at sun.plugin.util.GrayBoxPainter.access$200(GrayBoxPainter.java:37)
	at sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener.progressFinish(GrayBoxPainter.java:491)
	at sun.plugin.util.EventMulticaster.progressFinish(EventMulticaster.java:114)
	at sun.plugin.util.ProgressMonitor.unregisterSource(ProgressMonitor.java:176)
	at sun.net.ProgressSource.finishTracking(ProgressSource.java:137)
	at sun.net.www.http.KeepAliveStream.close(KeepAliveStream.java:91)
	at sun.net.www.MeteredStream.justRead(MeteredStream.java:75)
	at sun.net.www.MeteredStream.read(MeteredStream.java:117)
	at java.io.FilterInputStream.read(FilterInputStream.java:116)
	at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2385)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
	at sun.plugin2.applet.Applet2ClassLoader.getBytes(Applet2ClassLoader.java:549)
	at sun.plugin2.applet.Applet2ClassLoader.access$700(Applet2ClassLoader.java:55)
	at sun.plugin2.applet.Applet2ClassLoader$2.run(Applet2ClassLoader.java:224)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:221)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
	at sun.plugin2.applet.Applet2ClassLoader.loadCode(Applet2ClassLoader.java:864)
	at sun.plugin2.applet.Applet2Manager.createApplet(Applet2Manager.java:2835)
	at sun.plugin2.applet.Applet2Manager.access$2000(Applet2Manager.java:87)
	at sun.plugin2.applet.Applet2Manager$AppletExecutionRunnable.run(Applet2Manager.java:1399)
	at java.lang.Thread.run(Thread.java:619)

We need to guard against RuntimeExceptions propagating out of the GrayBoxPainter and use Trace.ignoredException() to display them, so that if tracing is turned off they don't pollute the Java Console output.

Comments
SUGGESTED FIX http://sa.sfbay.sun.com/projects/deployment_data/6u10/6648922.0
10-01-2008

EVALUATION Guarded against exceptions propagating out of the GrayBoxPainter to calling code by wrapping all methods that do any AWT or Java 2D work with try/catch blocks. Tested manually with previously failing applet, but as the failures are intermittent it's basically impossible to conclusively verify the fix.
10-01-2008