From 0f4bed9f16648410a811e98197d79fbd1d10fa6e Mon Sep 17 00:00:00 2001
From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com>
Date: Wed, 19 Jan 2022 14:10:50 +0600
Subject: [PATCH] Fix StackOverflowError in Transaction (#2827)
* Fix StackOverflowError in Transaction
* format import
* Modify exec() and discard() in Transaction
* add mockito-inline in pom
---
pom.xml | 2 +-
.../redis/clients/jedis/TransactionBase.java | 78 ++++++++++++-------
.../jedis/TransactionCommandsTest.java | 45 +++++++++++
3 files changed, 95 insertions(+), 30 deletions(-)
diff --git a/pom.xml b/pom.xml
index 603cb9b4f4..43a4f0572c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,7 +93,7 @@
org.mockito
- mockito-core
+ mockito-inline
3.12.4
test
diff --git a/src/main/java/redis/clients/jedis/TransactionBase.java b/src/main/java/redis/clients/jedis/TransactionBase.java
index 18139b2784..7ace1583d9 100644
--- a/src/main/java/redis/clients/jedis/TransactionBase.java
+++ b/src/main/java/redis/clients/jedis/TransactionBase.java
@@ -18,6 +18,7 @@
import redis.clients.jedis.commands.PipelineCommands;
import redis.clients.jedis.commands.ProtocolCommand;
import redis.clients.jedis.commands.RedisModulePipelineCommands;
+import redis.clients.jedis.exceptions.JedisConnectionException;
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.json.JsonSetParams;
import redis.clients.jedis.json.Path;
@@ -34,6 +35,7 @@ public abstract class TransactionBase extends Queable implements PipelineCommand
protected final Connection connection;
private final CommandObjects commandObjects;
+ private boolean broken = false;
private boolean inWatch = false;
private boolean inMulti = false;
@@ -93,6 +95,9 @@ public final void close() {
}
public final void clear() {
+ if (broken) {
+ return;
+ }
if (inMulti) {
discard();
} else if (inWatch) {
@@ -103,41 +108,56 @@ public final void clear() {
protected abstract void processPipelinedResponses();
public List