You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by up...@apache.org on 2016/04/14 01:55:29 UTC

incubator-geode git commit: GEODE-1018: Retrieve queues only once gateway listener to avoid a race

Repository: incubator-geode
Updated Branches:
  refs/heads/develop bbf705edc -> a885ac140


GEODE-1018: Retrieve queues only once gateway listener to avoid a race

The second call to getQueues could have returned null due to a
concurrent change. By fetching the queues only once we avoid a race.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/a885ac14
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/a885ac14
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/a885ac14

Branch: refs/heads/develop
Commit: a885ac140b50d4f3ec74ede9fcdff98623d8dc81
Parents: bbf705e
Author: Dan Smith <up...@apache.org>
Authored: Wed Apr 13 10:12:29 2016 -0700
Committer: Dan Smith <up...@apache.org>
Committed: Wed Apr 13 16:54:58 2016 -0700

----------------------------------------------------------------------
 .../serial/SerialSecondaryGatewayListener.java   | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a885ac14/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialSecondaryGatewayListener.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialSecondaryGatewayListener.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialSecondaryGatewayListener.java
index 5cb0ec0..8250270 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialSecondaryGatewayListener.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialSecondaryGatewayListener.java
@@ -16,10 +16,13 @@
  */
 package com.gemstone.gemfire.internal.cache.wan.serial;
 
+import java.util.Set;
+
 import org.apache.logging.log4j.Logger;
 
 import com.gemstone.gemfire.cache.EntryEvent;
 import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
+import com.gemstone.gemfire.internal.cache.RegionQueue;
 import com.gemstone.gemfire.internal.cache.wan.AbstractGatewaySender;
 import com.gemstone.gemfire.internal.cache.wan.GatewaySenderEventImpl;
 import com.gemstone.gemfire.internal.logging.LogService;
@@ -55,11 +58,8 @@ public class SerialSecondaryGatewayListener extends CacheListenerAdapter
    }
    // There is a small window where queue has not been created fully yet. 
    // The underlying region of the queue is created, and it receives afterDestroy callback
-   if (this.sender.getQueues() != null && !this.sender.getQueues().isEmpty()) {
-//     int size = 0;
-//     for(RegionQueue q: this.sender.getQueues()) {
-//       size += q.size();
-//     }
+   final Set<RegionQueue> queues = this.sender.getQueues();
+   if (queues != null && !queues.isEmpty()) {
      this.sender.getStatistics().incQueueSize();
    }
    // fix bug 35730
@@ -76,12 +76,9 @@ public class SerialSecondaryGatewayListener extends CacheListenerAdapter
    }
     // fix bug 37603
     // There is a small window where queue has not been created fully yet. The region is created, and it receives afterDestroy callback.
-   
-   if (this.sender.getQueues() != null && !this.sender.getQueues().isEmpty()) {
-//     int size = 0;
-//     for(RegionQueue q: this.sender.getQueues()) {
-//       size += q.size();
-//     }
+
+   final Set<RegionQueue> queues = this.sender.getQueues();
+   if (queues != null && !queues.isEmpty()) {
      this.sender.getStatistics().decQueueSize();
    }