Release OutboundQueueEntry callback on completion
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / core / connection / OutboundQueueEntry.java
index 48722dbbdd3d0db856fa83af27953b1e2dcc3e6a..4b8820bd9b430317e7dd4a6b0ddd6d65d091e0ea 100644 (file)
@@ -77,6 +77,10 @@ final class OutboundQueueEntry {
         completed = reallyComplete;
         if (callback != null) {
             callback.onSuccess(response);
+            if (reallyComplete) {
+                // We will not need the callback anymore, make sure it can be GC'd
+                callback = null;
+            }
         }
         LOG.debug("Entry {} completed {} with response {}", this, completed, response);
         return reallyComplete;
@@ -87,10 +91,10 @@ final class OutboundQueueEntry {
             completed = true;
             if (callback != null) {
                 callback.onFailure(cause);
+                callback = null;
             }
         } else {
             LOG.warn("Ignoring failure {} for completed message", cause);
         }
     }
-
 }