-
Notifications
You must be signed in to change notification settings - Fork 153
Description
Describe the bug
In our project, we sometimes recreate the ProducerClient to come out of idle channels scenario, we call Reset() on the producer client. Sometimes, we get terminated with the error: "Could not close message sender". Needless to ask, we have many try and catches in place to handle exceptions, but this exception was not handled.
Upon looking closer into the implementation, we got to the conclusion that Close() throws from the destructor, which is marked as noexcept, hence we terminate no matter what.
Close may throw that is fine but calling Close() from the destructor and then letting the exception propagate from destructor as per C++ standards will cause std::terminate to be called.
Close() is being called from here:
Line 101 in 04f2ce0
| ~ProducerClient() { Close(); } |
Exception or Stack Trace
"Could not close message sender", it comes from deep inside amqp implementation here:
azure-sdk-for-cpp/sdk/core/azure-core-amqp/src/impl/uamqp/amqp/message_sender.cpp
Line 401 in 04f2ce0
| if (messagesender_close(m_messageSender.get())) |
To Reproduce
We can create a minimal example where a destructor throws in C++17. Real scenarion is difficult to reproduce as the underlying channel needs to throw while closing, which we cannot mimic.
It only happens when close() throws, similar code can be checked to understand the issue where the destructor throws.
Expected behavior
The ~ProducerClient() should not throw.
Setup (please complete the following information):
We're using vcpkg installed version with C++17.
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- Bug Description Added
- Repro Steps Added
- Setup information Added