Skip to content

Commit 72e869b

Browse files
author
Bret Ambrose
committed
Use safe cast which isn't yet available in released CRT
1 parent d563648 commit 72e869b

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

eventstream_rpc/source/EventStreamClient.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,12 +2211,8 @@ namespace Aws
22112211
}
22122212
else
22132213
{
2214-
// Horribly awkward cast due to the infuriating original API design
2215-
Crt::Allocator *allocator = m_allocator;
2216-
auto errorResponse = Crt::ScopedResource<OperationError>(
2217-
static_cast<OperationError *>(result.m_message.value().m_shape.release()),
2218-
[allocator](OperationError *shape) { Crt::Delete(shape, allocator); });
2219-
2214+
auto errorResponse = Crt::SafeSubCast<AbstractShapeBase, OperationError>(
2215+
std::move(result.m_message.value().m_shape));
22202216
activationResultCallback(EventstreamResultVariantType(std::move(errorResponse)));
22212217
}
22222218
}
@@ -2248,11 +2244,8 @@ namespace Aws
22482244

22492245
case EventStreamMessageRoutingType::Error:
22502246
{
2251-
Crt::Allocator *allocator = m_allocator;
2252-
auto errorResponse = Crt::ScopedResource<OperationError>(
2253-
static_cast<OperationError *>(shape.release()),
2254-
[allocator](OperationError *shape) { Crt::Delete(shape, allocator); });
2255-
2247+
auto errorResponse =
2248+
Crt::SafeSubCast<AbstractShapeBase, OperationError>(std::move(shape));
22562249
shouldClose = streamHandler->OnStreamError(
22572250
std::move(errorResponse), {EVENT_STREAM_RPC_SUCCESS, 0});
22582251
break;

0 commit comments

Comments
 (0)