FYI [gui] Make EventQueue.postEvent(null) fail fast

Mark Wielaard mark@klomp.org
Tue Aug 3 23:29:00 GMT 2004


Hi,

Another merglet from GNU Classpath.

The following makes EventQueue.postEvent() throw a NullPointerException
immediately when it gets a null event.

2004-06-27  Mark Wielaard  <mark@klomp.org>

       * java/awt/EventQueue.java (postEvent): Throw NullPointerException
       when argument is null.

In the past a null event could slip through and only throw a
NullPointerException much later during event processing making debugging
horribly complicated. Committed to the gui branch.

Cheers,

Mark

--- java/awt/EventQueue.java    26 Jan 2004 16:33:01 -0000      1.16
+++ java/awt/EventQueue.java    27 Jun 2004 10:45:28 -0000
@@ -161,6 +161,9 @@
    */
   public synchronized void postEvent(AWTEvent evt)
   {
+    if (evt == null)
+      throw new NullPointerException();
+
     if (next != null)
       {
         next.postEvent(evt);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040803/42099aef/attachment.sig>


More information about the Java-patches mailing list