Skip to content

Commit

Permalink
Fix event marshaller binding for input event streams.
Browse files Browse the repository at this point in the history
This is another case of SDK code generation failing when the event's structure name and the structure member name are not identical.
  • Loading branch information
adamthom-amzn authored and millems committed Jun 30, 2020
1 parent 49bd2be commit 022970e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-AWSSDKforJavav2-410cf46.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"category": "AWS SDK for Java v2",
"type": "bugfix",
"description": "Fix marshaller binding for input event streams when member name and shape name are not equal."
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import software.amazon.awssdk.codegen.emitters.GeneratorTaskParams;
import software.amazon.awssdk.codegen.model.config.customization.UtilitiesMethod;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.intermediate.MemberModel;
import software.amazon.awssdk.codegen.model.intermediate.OperationModel;
import software.amazon.awssdk.codegen.model.intermediate.ShapeModel;
import software.amazon.awssdk.codegen.poet.PoetExtensions;
Expand Down Expand Up @@ -273,7 +272,7 @@ private CodeBlock createEventStreamTaggedUnionJsonMarshaller(ShapeModel eventStr
EventStreamTaggedUnionJsonMarshaller.class);

List<String> eventNames = EventStreamUtils.getEventMembers(eventStreamShape)
.map(MemberModel::getC2jName)
.map(m -> m.getShape().getShapeName())
.collect(Collectors.toList());

eventNames.forEach(event -> builder.add(".putMarshaller($T.class, new $T(protocolFactory))",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest;
import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse;
import software.amazon.awssdk.services.json.model.InputEvent;
import software.amazon.awssdk.services.json.model.InputEventOne;
import software.amazon.awssdk.services.json.model.InputEventStream;
import software.amazon.awssdk.services.json.model.InputEventStreamTwo;
import software.amazon.awssdk.services.json.model.InputEventTwo;
Expand All @@ -86,7 +85,6 @@
import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyOutputRequestMarshaller;
import software.amazon.awssdk.services.json.transform.GetWithoutRequiredMembersRequestMarshaller;
import software.amazon.awssdk.services.json.transform.InputEventMarshaller;
import software.amazon.awssdk.services.json.transform.InputEventOneMarshaller;
import software.amazon.awssdk.services.json.transform.InputEventTwoMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithResultKeyRequestMarshaller;
import software.amazon.awssdk.services.json.transform.PaginatedOperationWithoutResultKeyRequestMarshaller;
Expand Down Expand Up @@ -343,7 +341,7 @@ public CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamO
HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
.putMarshaller(InputEventOne.class, new InputEventOneMarshaller(protocolFactory))
.putMarshaller(InputEvent.class, new InputEventMarshaller(protocolFactory))
.putMarshaller(InputEventTwo.class, new InputEventTwoMarshaller(protocolFactory)).build();
SdkPublisher<InputEventStreamTwo> eventPublisher = SdkPublisher.adapt(requestStream);
Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(
Expand Down

0 comments on commit 022970e

Please sign in to comment.