Skip to content

Commit b286305

Browse files
yfeldblumfacebook-github-bot
authored andcommitted
exception_wrapper thrown variant via abi/runtime
Summary: Reimplement `folly::exception_wrapper` thrown variant not to need to cache any pointers and rather to access the exception object and runtime type, and to perform runtime upcasting, via the platform runtime. This both simplifies and extends the capability of the thrown variant. Reviewed By: luciang Differential Revision: D26331579 fbshipit-source-id: a6fe0f10434956efa5ba4b4bcd1bd3a1b48466a4
1 parent 8bb3f12 commit b286305

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

rsocket/test/transport/TcpDuplexConnectionTest.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,5 @@ TEST(TcpDuplexConnection, ConnectionAndSubscribersAreUntied) {
109109
worker.getEventBase());
110110
}
111111

112-
TEST(TcpDuplexConnection, ExceptionWrapperTest) {
113-
folly::AsyncSocketException socketException(
114-
folly::AsyncSocketException::AsyncSocketExceptionType::INVALID_STATE,
115-
"test",
116-
10);
117-
folly::SSLException sslException(5, 10, 15, 20);
118-
119-
const folly::AsyncSocketException& socketExceptionRef = sslException;
120-
121-
folly::exception_wrapper ex1(socketException);
122-
folly::exception_wrapper ex2(sslException);
123-
124-
// Slicing error:
125-
// folly::exception_wrapper ex3(socketExceptionRef);
126-
127-
// Fixed version:
128-
folly::exception_wrapper ex3(
129-
std::make_exception_ptr(socketExceptionRef), socketExceptionRef);
130-
}
131-
132112
} // namespace tests
133113
} // namespace rsocket

rsocket/transports/tcp/TcpDuplexConnection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class TcpReaderWriter : public folly::AsyncTransportWrapper::WriteCallback,
109109

110110
void writeErr(size_t, const folly::AsyncSocketException& exn) noexcept
111111
override {
112-
closeErr(folly::exception_wrapper{std::make_exception_ptr(exn), exn});
112+
closeErr(folly::exception_wrapper{folly::copy(exn)});
113113
intrusive_ptr_release(this);
114114
}
115115

@@ -134,7 +134,7 @@ class TcpReaderWriter : public folly::AsyncTransportWrapper::WriteCallback,
134134
}
135135

136136
void readErr(const folly::AsyncSocketException& exn) noexcept override {
137-
closeErr(folly::exception_wrapper{std::make_exception_ptr(exn), exn});
137+
closeErr(folly::exception_wrapper{folly::copy(exn)});
138138
intrusive_ptr_release(this);
139139
}
140140

0 commit comments

Comments
 (0)