[6023] in Moira

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

Re: Patch for transient NPEs in Regapplet

daemon@ATHENA.MIT.EDU (Garry P Zacheiss)
Wed Apr 20 23:30:48 2011

From: Garry P Zacheiss <zacheiss@MIT.EDU>
To: Jonathan D Reed <jdreed@mit.edu>
CC: "moiradev@mit.edu" <moiradev@mit.edu>
Date: Wed, 20 Apr 2011 23:30:39 -0400
Message-ID: <F707856F-03DD-4239-878A-E34DF5D2B1BB@exchange.mit.edu>
In-Reply-To: <95790492-D016-4673-B784-D5840C273AEC@mit.edu>
Content-Language: en-US
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Seems reasonable.   Checked in and deployed.

Garry

On Apr 20, 2011, at 8:28 PM, Jonathan Reed wrote:

> 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?
> 
> Thanks, 
> 
> Jon
> 
> 
> 
> Index: clients/regapplet/regapplet/TextBlock.java
> ===================================================================
> --- clients/regapplet/regapplet/TextBlock.java	(revision 4031)
> +++ clients/regapplet/regapplet/TextBlock.java	(working copy)
> @@ -11,6 +11,7 @@
>     super();
>     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