Skip to content

Commit 4ad5c29

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Fix deprecated this capture in thrift/lib/cpp2/test/server/ThriftServerTest.cpp
Summary: In the future LLVM will require that lambdas capture `this` explicitly. `-Wdeprecated-this-capture` checks for and enforces this now. This diff adds an explicit `this` capture to a lambda to fix an issue that presents similarly to this: ``` -> fbcode/path/to/my_file.cpp:66:47: error: implicit capture of 'this' with a capture default of '=' is deprecated [-Werror,- Wdeprecated-this-capture] -> detail::createIOWorkerProvider(evb, requestsRegistry_); -> ^ -> fbcode/path/to/my_file.cpp:61:30: note: add an explicit capture of 'this' to capture '*this' by reference -> evb->runInEventBaseThread([=, self_weak = std::move(self_weak)]() { -> ^ -> , this ``` Differential Revision: D80966457 fbshipit-source-id: 070a0a2407b54526fcd758533a69661e2d9df410
1 parent bb0f47c commit 4ad5c29

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

third-party/thrift/src/thrift/lib/cpp2/test/server/ThriftServerTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ TEST_P(HeaderOrRocket, StickyToThreadPool) {
15331533
folly::SemiFuture<folly::Unit> semifuture_priorityHigh() override {
15341534
EXPECT_THAT(
15351535
*folly::getCurrentThreadName(), testing::StartsWith("foo-pri1"));
1536-
return folly::makeSemiFuture().defer([=](auto&&) {
1536+
return folly::makeSemiFuture().defer([=, this](auto&&) {
15371537
callCount_++;
15381538
EXPECT_THAT(
15391539
*folly::getCurrentThreadName(), testing::StartsWith("foo-pri1"));

third-party/thrift/src/thrift/lib/py/server/CppServerWrapper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ class PythonAsyncProcessor : public AsyncProcessor {
262262
}
263263

264264
auto task = [=,
265+
this,
265266
reqCaptured = std::move(req),
266267
serializedCompressedRequestCaptured =
267268
std::move(serializedCompressedRequest),

third-party/thrift/src/thrift/lib/python/client/test/omni_client_test.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -231,24 +231,25 @@ class OmniClientTest : public ::testing::Test {
231231
const Result& expected,
232232
const RpcKind rpcKind = RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE,
233233
const bool clearEventHandlers = false) {
234-
connectToServer<S>([=](OmniClient& client) -> folly::coro::Task<void> {
235-
if (clearEventHandlers) {
236-
client.clearEventHandlers();
237-
}
238-
std::string args = S::template serialize<std::string>(req);
239-
auto data = apache::thrift::MethodMetadata::Data(
240-
function, apache::thrift::FunctionQualifier::Unspecified);
241-
auto resp = co_await client.semifuture_send(
242-
service,
243-
function,
244-
args,
245-
std::move(data),
246-
headers,
247-
{},
248-
co_await folly::coro::co_current_executor,
249-
rpcKind);
250-
testContains<S>(std::move(resp.buf.value()), expected);
251-
});
234+
connectToServer<S>(
235+
[=, this](OmniClient& client) -> folly::coro::Task<void> {
236+
if (clearEventHandlers) {
237+
client.clearEventHandlers();
238+
}
239+
std::string args = S::template serialize<std::string>(req);
240+
auto data = apache::thrift::MethodMetadata::Data(
241+
function, apache::thrift::FunctionQualifier::Unspecified);
242+
auto resp = co_await client.semifuture_send(
243+
service,
244+
function,
245+
args,
246+
std::move(data),
247+
headers,
248+
{},
249+
co_await folly::coro::co_current_executor,
250+
rpcKind);
251+
testContains<S>(std::move(resp.buf.value()), expected);
252+
});
252253
}
253254

254255
template <class S = CompactSerializer, class Request, class Result>

0 commit comments

Comments
 (0)