United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6648922 Exceptions in GrayBoxPainter can cause applet to not load
6648922 : Exceptions in GrayBoxPainter can cause applet to not load

Details
Type:
Bug
Submit Date:
2008-01-10
Status:
Closed
Updated Date:
2010-09-17
Project Name:
JDK
Resolved Date:
2008-01-31
Component:
deploy
OS:
generic
Sub-Component:
plugin
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u10
Fixed Versions:
6u10

Related Reports
Backport:

Sub Tasks

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
                                     
2008-01-10
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.
                                     
2008-01-10



Hardware and Software, Engineered to Work Together