diff options
author | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-03-14 11:15:11 +0300 |
---|---|---|
committer | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-03-14 11:15:11 +0300 |
commit | ea643713e962d8ba3084bb62c650717573a54123 (patch) | |
tree | 41e1b71bc4891940e9a61280b6a3c3b82b8e0f78 | |
parent | 6b0a68b8c3dc333edceb2821c88939fa14b99a96 (diff) | |
download | ydb-ea643713e962d8ba3084bb62c650717573a54123.tar.gz |
fix leak
-rw-r--r-- | ydb/core/testlib/common_helper.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/ydb/core/testlib/common_helper.cpp b/ydb/core/testlib/common_helper.cpp index 6b97f6d1e10..8b285542afa 100644 --- a/ydb/core/testlib/common_helper.cpp +++ b/ydb/core/testlib/common_helper.cpp @@ -26,19 +26,25 @@ void THelper::StartDataRequest(const TString& request, const bool expectSuccess, auto expectation = expectSuccess; bool resultReady = false; bool* rrPtr = &resultReady; - std::optional<NYdb::NTable::TDataQueryResult> resultInternal; - tClient.CreateSession().Subscribe([&resultInternal, rrPtr, request, expectation](NThreading::TFuture<NYdb::NTable::TCreateSessionResult> f) { + tClient.CreateSession().Subscribe([this, result, rrPtr, request, expectation](NThreading::TFuture<NYdb::NTable::TCreateSessionResult> f) { auto session = f.GetValueSync().GetSession(); session.ExecuteDataQuery(request , NYdb::NTable::TTxControl::BeginTx(NYdb::NTable::TTxSettings::SerializableRW()).CommitTx()) - .Subscribe([&resultInternal, rrPtr, expectation, request](NYdb::NTable::TAsyncDataQueryResult f) + .Subscribe([this, result, rrPtr, expectation, request](NYdb::NTable::TAsyncDataQueryResult f) { - resultInternal = f.GetValueSync(); TStringStream ss; f.GetValueSync().GetIssues().PrintTo(ss, false); Cerr << "REQUEST=" << request << ";RESULT=" << ss.Str() << ";EXPECTATION=" << expectation << Endl; UNIT_ASSERT(expectation == f.GetValueSync().IsSuccess()); *rrPtr = true; + if (result && expectation) { + TStringStream ss; + NYson::TYsonWriter writer(&ss, NYson::EYsonFormat::Text); + for (auto&& i : f.GetValueSync().GetResultSets()) { + PrintResultSet(i, writer); + } + *result = ss.Str(); + } }); }); const TInstant start = TInstant::Now(); @@ -47,15 +53,6 @@ void THelper::StartDataRequest(const TString& request, const bool expectSuccess, } Cerr << "REQUEST=" << request << ";EXPECTATION=" << expectation << Endl; UNIT_ASSERT(resultReady); - UNIT_ASSERT(resultInternal); - if (result) { - TStringStream ss; - NYson::TYsonWriter writer(&ss, NYson::EYsonFormat::Text); - for (auto&& i : resultInternal->GetResultSets()) { - PrintResultSet(i, writer); - } - *result = ss.Str(); - } } void THelper::StartSchemaRequest(const TString& request, const bool expectSuccess, const bool waiting) const { |