ITADN

Close() throws exception from the destructor of ProducerClient causing the users to terminate, without an opportunity to catch the exception

#6958OpenDeepa-Pathak 创建于 2026-02-16
questionneeds-triagecustomer-reported
D
Deepa-Pathakcommented
**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 is as per C++ standards will cause std::terminate to be called. ***Exception or Stack Trace*** "Could not close message sender", it comes from deep inside amqp implementation here: https://github.com/Azure/azure-sdk-for-cpp/blob/04f2ce086af80d41892bfffd645c891b36c98961/sdk/core/azure-core-amqp/src/impl/uamqp/amqp/message_sender.cpp#L401 **To Reproduce** We can create a minimal example where a destructor throws in C++17. ***Code Snippet*** Add the code snippet that causes the issue. **Expected behavior** The ~ProducerClient() should not throw. **Screenshots** If applicable, add screenshots to help explain your problem. **Setup (please complete the following information):** We're using vcpkg installed version in Rhel9 with C++17. **Additional context** Add any other context about the problem here. **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 - [x] Bug Description Added - [x] Repro Steps Added - [x] Setup information Added
0 条评论