debasishg / scala-redis

A scala library for connecting to a redis server, or a cluster of redis nodes using consistent hashing on the client side.
1.02k stars 219 forks source link

Make sure Redis.send(..) methods are tail recursive #302

Open sptz45 opened 1 year ago

sptz45 commented 1 year ago

We need to do that cause if we have a faulty Redis server that has issues with connections the reconnect-on-error functionality of those methods can result in StackOverflowError.

We had to create a private method for each send(..) method cause simply adding @tailrec would produce the following compiler error: "could not optimize @tailrec annotated method send: it is neither private nor final so can be overridden". We also opted for adding private methods instead of defining them inside each method in order to make fewer changes and better preserve the git history.