Refine RedisException
instantiation to avoid exception instances if they are not used
#2353
Labels
type: feature
A new feature
Milestone
Bug Report
Current Behavior
We are using NewRelic to monitor our AWS Redis cluster which uses Lettuce as the client. Upon upgrading NewRelic client to the newest, it has suddenly started to warn us about high volume of RedisExceptions. All of these exceptions did not come from our code but instead from a separate thread (I assume this thread is launched/by Lettuce). I've tried to reproduce it locally and ended up with the following code:
Input Code
The code above uses local Redis cluster (
docker run -e "IP=0.0.0.0" -p 7000-7005:7000-7005 grokzen/redis-cluster:latest
).I ran this code with IntelliJ and asked it to log a line every time RedisException is initialized. The output is as follows:
Expected behavior/code
Above suggests RedisException was constructed (not necessarily thrown!) 41 times.
The exception message is always the same, "Connection closed".
Can you comment whether such liberal usage of exceptions is by design or is this a bug?
I guess we could block this exception in NewRelic but this would likely shield us from spotting actual Redis errors.
Environment
Possible Solution
Avoid excessive usage of exceptions for they are expensive to create (Effective Java et al).
The text was updated successfully, but these errors were encountered: