Author: toad
Date: 2008-01-25 17:37:13 +0000 (Fri, 25 Jan 2008)
New Revision: 17286

Modified:
   trunk/freenet/src/freenet/io/comm/MessageFilter.java
Log:
Doh. Prevent NPE, take the lock only once.

Modified: trunk/freenet/src/freenet/io/comm/MessageFilter.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/MessageFilter.java        2008-01-25 
17:31:29 UTC (rev 17285)
+++ trunk/freenet/src/freenet/io/comm/MessageFilter.java        2008-01-25 
17:37:13 UTC (rev 17286)
@@ -289,14 +289,19 @@
      * Hopefully no locks will be held at this point by the caller.
      */
        public void onMatched() {
-               if(_callback != null) {
+               Message msg;
+               AsyncMessageFilterCallback cb;
+               synchronized(this) {
+                       msg = _message;
+                       cb = _callback;
                        // Clear matched before calling callback in case we are 
re-added.
-                       clearMatched();
-                       _callback.onMatched(_message);
-               }
-               synchronized(this) {
+                       if(_callback != null)
+                               clearMatched();
                        notifyAll();
                }
+               if(cb != null) {
+                       cb.onMatched(msg);
+               }
        }

        /**


Reply via email to