BUG 8301: Convert queue to a local variable 72/56472/1
authorTomas Cere <tcere@cisco.com>
Wed, 3 May 2017 11:12:31 +0000 (13:12 +0200)
committerRobert Varga <nite@hq.sk>
Wed, 3 May 2017 14:29:21 +0000 (14:29 +0000)
There's a possibility that this might race and an
actor can have it's queue overwritten by another thread, so convert
this to a local variable.

Change-Id: Ic84922c6d109d8361a48debbf971fddd9cee1d3e
Signed-off-by: Tomas Cere <tcere@cisco.com>

index f69c316..c56863f 100644 (file)
@@ -26,7 +26,6 @@ public class MeteredBoundedMailbox implements MailboxType,
     private static final Logger LOG = LoggerFactory.getLogger(MeteredBoundedMailbox.class);
     private static final String QUEUE_SIZE = "q-size";
-    private MeteredMessageQueue queue;
     private final Integer capacity;
     private final FiniteDuration pushTimeOut;
     private final MetricRegistry registry;
@@ -44,9 +43,9 @@ public class MeteredBoundedMailbox implements MailboxType,
     public MeteredMessageQueue create(final scala.Option<ActorRef> owner, scala.Option<ActorSystem> system) {
-        this.queue = new MeteredMessageQueue(this.capacity, this.pushTimeOut);
-        monitorQueueSize(owner, this.queue);
-        return this.queue;
+        final MeteredMessageQueue queue = new MeteredMessageQueue(this.capacity, this.pushTimeOut);
+        monitorQueueSize(owner, queue);
+        return queue;
     private void monitorQueueSize(scala.Option<ActorRef> owner, final MeteredMessageQueue monitoredQueue) {

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.