Skip to content

Commit 6290f90

Browse files
author
Alexandre Curreli
committed
Also handling the case where no commands get queued in a transaction
1 parent 7d84d3d commit 6290f90

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main/scala/scredis/protocol/requests/TransactionRequests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object TransactionRequests {
2323
decoders: Seq[Decoder[Any]]
2424
) extends Request[Vector[Try[Any]]](Exec) {
2525
override def decode = {
26-
case a: ArrayResponse => if (a.length > 0) {
26+
case a: ArrayResponse => if (a.length >= 0) {
2727
a.parsed[Vector](decoders)
2828
} else {
2929
throw RedisTransactionAbortedException

src/test/scala/scredis/commands/TransactionCommandsSpec.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ class TransactionCommandsSpec extends WordSpec
5454
}
5555

5656
"inTransaction" when {
57+
"no commands are queued" should {
58+
"succeed" taggedAs (V120) in {
59+
client.inTransaction(_ => ()).futureValue should be (empty)
60+
}
61+
}
5762
"all commands are valid" should {
5863
"succeed" taggedAs (V120) in {
5964
client.set("STR", SomeValue)
@@ -108,6 +113,11 @@ class TransactionCommandsSpec extends WordSpec
108113
}
109114

110115
"withTransaction" when {
116+
"no commands are queued" should {
117+
"succeed" taggedAs (V120) in {
118+
client.withTransaction(_ => ()) should be (())
119+
}
120+
}
111121
"all commands are valid" should {
112122
"succeed" taggedAs (V120) in {
113123
client.set("STR", SomeValue)

0 commit comments

Comments
 (0)