diff --git a/.changes/next-release/bugfix-AWSSDKforJavav2-410cf46.json b/.changes/next-release/bugfix-AWSSDKforJavav2-410cf46.json new file mode 100644 index 000000000000..d5c08b960949 --- /dev/null +++ b/.changes/next-release/bugfix-AWSSDKforJavav2-410cf46.json @@ -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." +} diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java index b7045285fd95..d44068d9525a 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java @@ -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; @@ -273,7 +272,7 @@ private CodeBlock createEventStreamTaggedUnionJsonMarshaller(ShapeModel eventStr EventStreamTaggedUnionJsonMarshaller.class); List 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))", diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-async-client-class.java index 853adc50a05d..d7c8db61ddfe 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-async-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-async-client-class.java @@ -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; @@ -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; @@ -343,7 +341,7 @@ public CompletableFuture eventStreamO HttpResponseHandler 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 eventPublisher = SdkPublisher.adapt(requestStream); Publisher adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(