[6022] in Moira

home help back first fref pref prev next nref lref last post

Patch for transient NPEs in Regapplet

daemon@ATHENA.MIT.EDU (Jonathan Reed)
Wed Apr 20 20:28:16 2011

From: Jonathan Reed <jdreed@MIT.EDU>
Content-Type: text/plain; charset=us-ascii
Date: Wed, 20 Apr 2011 20:28:08 -0400
Message-Id: <95790492-D016-4673-B784-D5840C273AEC@mit.edu>
To: moiradev@mit.edu
Mime-Version: 1.0 (Apple Message framework v1084)
Content-Transfer-Encoding: 8bit

Under some JREs (OpenJDK, for example), the Regapplet occasionally fails to load.  We traced it down to a transient NPE in TextBlock.paint(), namely that the variable "text" was null, so calls to text.length() were throwing exceptions.  I'm not sure why it was null, but my current theory is that basically it's the result of a race condition between the applet making itself visible and the call to setText in MessagePanel.java.  Once it's visible, paint() is called, and if text is null, we lose.  The following patch fixes this by ensuring that TextBlock.text always has some value.  It should not affect the final displayed result, since the text is eventually set, TextBlock.setText() calls invalidate() on the Canvas parent class, which will then result in another call to paint().

Would it be possible to take this patch and push out a new version of the applet?



Index: clients/regapplet/regapplet/TextBlock.java
--- clients/regapplet/regapplet/TextBlock.java	(revision 4031)
+++ clients/regapplet/regapplet/TextBlock.java	(working copy)
@@ -11,6 +11,7 @@
     width = x;
     height = y;
+    text = "<undefined>";
   public Dimension minimumSize() {
     System.err.println("TextBlock: minimumSize called " + width + " " + height);

home help back first fref pref prev next nref lref last post