qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject svn commit: r1032291 - /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageReference.java
Date Sun, 07 Nov 2010 14:51:05 GMT
Author: robbie
Date: Sun Nov  7 14:51:05 2010
New Revision: 1032291

URL: http://svn.apache.org/viewvc?rev=1032291&view=rev
Log:
QPID-2931: update MessageReference to stop nulling out the ServerMessage reference upon release
for now, preventing NPE's experienced due to race conditions resulting in use of getMessage()
after release.

Modified:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageReference.java

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageReference.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageReference.java?rev=1032291&r1=1032290&r2=1032291&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageReference.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageReference.java
Sun Nov  7 14:51:05 2010
@@ -20,13 +20,12 @@
  */
 package org.apache.qpid.server.message;
 
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 public abstract class MessageReference<M extends ServerMessage>
 {
 
-    private static final AtomicReferenceFieldUpdater<MessageReference, ServerMessage>
_messageUpdater =
-            AtomicReferenceFieldUpdater.newUpdater(MessageReference.class, ServerMessage.class,"_message");
+    private final AtomicBoolean _released = new AtomicBoolean(false);
 
     private volatile M _message;
 
@@ -47,10 +46,12 @@ public abstract class MessageReference<M
 
     public void release()
     {
-        M message = (M) _messageUpdater.getAndSet(this,null);
-        if(message != null)
+        if(!_released.getAndSet(true))
         {
-            onRelease(message);
+            if(_message != null)
+            {
+                onRelease(_message);
+            }
         }
     }
 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message