Fix exception fix in TraceCollector dtor

Cf. #44758

Function try blocks in ctors/dtors implicitly rethrow, making them
more or less useless.

https://www.onlinegdb.com/pCKQA0wTIN (click RUN)

https://stackoverflow.com/questions/5612486/when-is-a-function-try-block-useful/5612508#5612508

Fortunately, this seems the only place like that in the codebase.
This commit is contained in:
Robert Schulze 2023-01-05 18:22:47 +00:00
parent 078f4d947a
commit 9ef7dac0b5
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A

View File

@ -31,18 +31,20 @@ TraceCollector::TraceCollector(std::shared_ptr<TraceLog> trace_log_)
TraceCollector::~TraceCollector()
try
{
if (!thread.joinable())
LOG_ERROR(&Poco::Logger::get("TraceCollector"), "TraceCollector thread is malformed and cannot be joined");
else
stop();
try
{
if (!thread.joinable())
LOG_ERROR(&Poco::Logger::get("TraceCollector"), "TraceCollector thread is malformed and cannot be joined");
else
stop();
TraceSender::pipe.close();
}
catch (...)
{
tryLogCurrentException("TraceCollector");
TraceSender::pipe.close();
}
catch (...)
{
tryLogCurrentException("TraceCollector");
}
}