Ensure RedisPipeline dtor not to throw#1115
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This PR adds exception handling to the RedisPipeline destructor to prevent exceptions from propagating out of the destructor, which is a C++ best practice. The change wraps the existing flush() call in a try-catch block that catches both std::exception and generic exceptions, logging appropriate error messages.
Key changes:
- Wrapped
flush()call in destructor with try-catch blocks to prevent exception propagation - Added error logging for both specific exceptions and unknown exceptions during flush
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
The coverage missing is due to no unit test covering proventative code path. It is easy to cover one line by shutdown redis. Other lines are difficult. There is challenge to cover them in unit test. It should be safe and no extra harm to merge. It is preventative code path. Originally code will crash in the same situation. catch (const std::exception& e)catch (...) |
Best practice says to not let exceptions propagate out of a destructor. So swallow any exception if it really throws in RedisPipeline class.