You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by zh...@apache.org on 2020/09/09 06:49:09 UTC
[geode] branch feature/GEODE-8485 created (now 80674d9)
This is an automated email from the ASF dual-hosted git repository.
zhouxj pushed a change to branch feature/GEODE-8485
in repository https://gitbox.apache.org/repos/asf/geode.git.
at 80674d9 GEODE-8485: When connection is closed, its server could be null
This branch includes the following new commits:
new 80674d9 GEODE-8485: When connection is closed, its server could be null
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[geode] 01/01: GEODE-8485: When connection is closed,
its server could be null
Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
zhouxj pushed a commit to branch feature/GEODE-8485
in repository https://gitbox.apache.org/repos/asf/geode.git
commit 80674d92d6ab41320b0aab7c918938b2f3ff7a46
Author: zhouxh <gz...@pivotal.io>
AuthorDate: Tue Sep 8 23:47:47 2020 -0700
GEODE-8485: When connection is closed, its server could be null
---
.../wan/GatewaySenderEventRemoteDispatcher.java | 3 ++-
...atewaySenderEventRemoteDispatcherJUnitTest.java | 24 +++++++++++++++++++++-
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java b/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
index 1f14d26..8717674 100644
--- a/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
+++ b/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcher.java
@@ -296,6 +296,7 @@ public class GatewaySenderEventRemoteDispatcher implements GatewaySenderEventDis
// THEN initialize the connection
if (!this.sender.isParallel()) {
if (this.connection == null || this.connection.isDestroyed()
+ || this.connection.getServer() == null
|| !this.connection.getServer().equals(this.sender.getServerLocation())) {
if (logger.isDebugEnabled()) {
logger.debug(
@@ -351,7 +352,7 @@ public class GatewaySenderEventRemoteDispatcher implements GatewaySenderEventDis
* Initializes the <code>Connection</code>.
*
*/
- private void initializeConnection() throws GatewaySenderException, GemFireSecurityException {
+ void initializeConnection() throws GatewaySenderException, GemFireSecurityException {
if (ackReaderThread != null) {
ackReaderThread.shutDownAckReaderConnection(connection);
}
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcherJUnitTest.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcherJUnitTest.java
index 0b5c8ed..d0360d1 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcherJUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcherJUnitTest.java
@@ -17,12 +17,16 @@ package org.apache.geode.internal.cache.wan;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.junit.Test;
-
+import org.apache.geode.cache.client.internal.Connection;
public class GatewaySenderEventRemoteDispatcherJUnitTest {
@Test
@@ -54,4 +58,22 @@ public class GatewaySenderEventRemoteDispatcherJUnitTest {
dispatcher.shutDownAckReaderConnection();
assertTrue(ackReaderThread.isShutdown());
}
+
+ @Test
+ public void getConnectionShouldCreateNewConnectionWhenServerIsNull() {
+ AbstractGatewaySender sender = mock(AbstractGatewaySender.class);
+ when(sender.isParallel()).thenReturn(false);
+ AbstractGatewaySenderEventProcessor eventProcessor =
+ mock(AbstractGatewaySenderEventProcessor.class);
+ when(eventProcessor.getSender()).thenReturn(sender);
+ Connection connection = mock(Connection.class);
+ when(connection.isDestroyed()).thenReturn(false);
+ when(connection.getServer()).thenReturn(null);
+ GatewaySenderEventRemoteDispatcher dispatcher =
+ new GatewaySenderEventRemoteDispatcher(eventProcessor, connection);
+ dispatcher = spy(dispatcher);
+ doNothing().when(dispatcher).initializeConnection();
+ Connection newConnection = dispatcher.getConnection(true);
+ verify(dispatcher, times(1)).initializeConnection();
+ }
}