geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ash...@apache.org
Subject [1/9] incubator-geode git commit: GEODE-537 Fix NPE in JTA AFTER_COMPLETION during rollback
Date Wed, 11 Nov 2015 21:22:09 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-11 37cc70edf -> 3af1540f6


GEODE-537 Fix NPE in JTA AFTER_COMPLETION during rollback

A fix for NullPointerException thrown on the server side and propagated to the Gemfire client
in case when active JTA transaction gets rolled back.


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

Branch: refs/heads/feature/GEODE-11
Commit: 0f72d363bae43a11f0c6d132076b99aedd8d834a
Parents: cfbeaf2
Author: sshcherbakov <sshcherbakov@gopivotal.com>
Authored: Mon Nov 9 23:21:54 2015 +0100
Committer: sshcherbakov <sshcherbakov@gopivotal.com>
Committed: Mon Nov 9 23:30:22 2015 +0100

----------------------------------------------------------------------
 .../tier/sockets/command/CommitCommand.java     |  4 +-
 .../tier/sockets/command/CommitCommandTest.java | 39 ++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0f72d363/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/CommitCommand.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/CommitCommand.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/CommitCommand.java
index 8d77874..6caf89a 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/CommitCommand.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/CommitCommand.java
@@ -119,7 +119,9 @@ public class CommitCommand extends BaseCommand {
     responseMsg.setMessageType(MessageType.RESPONSE);
     responseMsg.setTransactionId(origMsg.getTransactionId());
     responseMsg.setNumberOfParts(1);
-    response.setClientVersion(servConn.getClientVersion());
+    if( response != null ) {
+    	response.setClientVersion(servConn.getClientVersion());
+    }
     responseMsg.addObjPart(response, zipValues);
     servConn.getCache().getCancelCriterion().checkCancelInProgress(null);
     if (logger.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0f72d363/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/CommitCommandTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/CommitCommandTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/CommitCommandTest.java
new file mode 100644
index 0000000..1f9ce54
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/CommitCommandTest.java
@@ -0,0 +1,39 @@
+package com.gemstone.gemfire.internal.cache.tier.sockets.command;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+import com.gemstone.gemfire.CancelCriterion;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.internal.cache.tier.sockets.Message;
+import com.gemstone.gemfire.internal.cache.tier.sockets.ServerConnection;
+
+public class CommitCommandTest {
+
+	/**
+	 * Test for GEODE-537
+	 * No NPE should be thrown from the {@link CommitCommand.writeCommitResponse()}
+	 * if the response message is null as it is the case when JTA
+	 * transaction is rolled back with TX_SYNCHRONIZATION AFTER_COMPLETION STATUS_ROLLEDBACK

+	 * @throws IOException 
+	 * 
+	 */
+	@Test
+	public void testWriteNullResponse() throws IOException {
+		
+		Cache cache = mock(Cache.class);
+		Message origMsg = mock(Message.class);
+		ServerConnection servConn = mock(ServerConnection.class);
+		when(servConn.getResponseMessage()).thenReturn(mock(Message.class));
+		when(servConn.getCache()).thenReturn(cache);
+		when(cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class));
+		
+		CommitCommand.writeCommitResponse(null, origMsg, servConn);
+		
+	}
+	
+}


Mime
View raw message