Skip to content

Json Marshaller Migration To Poet #402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2018

Conversation

zoewangg
Copy link
Contributor

Description

Related to #30
To favor our new practices of making PR smaller and getting reviewed faster. This task is broken into the the following parts:

  1. Marshaller Refactor
    a. Json, rest-json marshaller
    b. query xml, rest-xml, ec2 marshaller
    c. api gateway marshaller

  2. Unmarshaller Refacctor
    a. Json, rest-json marshaller
    b. query xml, rest-xml, ec2 marshaller
    c. api gateway marshaller

This PR is for 1.a Json, rest-json marshaller

Motivation and Context

  • Replacing freemarker with poet
  • Removing unused files.

Testing

mvn clean install and integration test

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • [] My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • [] A short description of the change has been added to the CHANGELOG

License

  • I confirm that this pull request can be released under the Apache 2 license

@zoewangg zoewangg changed the title Json Marshaller Refactor Json Marshaller Migration To Poet Jan 31, 2018
Copy link
Contributor

@shorea shorea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No major concerns. Are the protocol tests passing?

public Template getModelMarshallerTemplate() throws IOException {
return getTemplate(templateConfig.getModelMarshaller());
}

public Template getRequestMarshallerTemplate() throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this still be used by other protocols?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this is only used by json protocol.

private final ClassName requestClassName;

public JsonModelMarshallerSpec(IntermediateModel intermediateModel, ShapeModel shapeModel, String className) {
final PoetExtensions poetExtensions = new PoetExtensions(intermediateModel);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant finals, we don't usually do that for locals, especially in Java8

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intellij auto created it. Will update the setting and this.

.addAnnotation(PoetUtils.GENERATED)
.addAnnotation(SdkInternalApi.class)
.addMethods(marshalMethods())
.addFields(memberVariables())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it doesn't matter since poet orders correctly but order is opposite of what i'd expect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that poet does reorder annotations - I'm fairly sure they'll go on in the order that they're called on the builder....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or did you mean fields/methods (that it does do correctly)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah fields and methods, here the member variables are added after the method but poet rearranges it. just looked weird when reading it


methodSpecs.add(constructor());
methodSpecs.add(getInstanceMethod());
methodSpecs.add(marshalMethod());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a two 'l' guy myself but apparently both spellings are valid. ¯_(ツ)_/¯

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should definitely choose one and be consistent!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two 'l' it is!

initializationCodeBlockBuilder.add(".marshallLocationName($S)", memberModel.getHttp().getMarshallLocationName());
}

if (memberModel.getIsBinary()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just always set this explicitly? If not can we inline true rather than consult getIsBinary again.

import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.utils.Validate;

public class MarshallerSpec implements ClassSpec {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly sure what this is for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the high level class used inMarshallerGeneratorTasks to create the marshaller class and it uses different implementations of MarshallerProtocolSpec to add the marshaller methods based on the protocol. This PR only contains JsonMarshallerSpec. This class is similar to AsyncClientClass

ProtocolMarshaller protocolMarshaller) {
Validate.paramNotNull(operationWithNoInputOrOutputRequest, "operationWithNoInputOrOutputRequest");
Validate.paramNotNull(protocolMarshaller, "protocolMarshaller");
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be nice to get rid of this if it's easy to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point

public void marshall(StreamingInputOperationRequest streamingInputOperationRequest, ProtocolMarshaller protocolMarshaller) {
Validate.paramNotNull(streamingInputOperationRequest, "streamingInputOperationRequest");
Validate.paramNotNull(protocolMarshaller, "protocolMarshaller");
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right, shouldn't it be marshalling the streaming member?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we use StreamingRequestMarshaller to marshall all streaming members in v2?

@zoewangg zoewangg force-pushed the MarshallerRefactor branch 2 times, most recently from e42a39d to 61af631 Compare February 2, 2018 21:48
@zoewangg zoewangg merged commit 713066c into aws:master Feb 3, 2018
@zoewangg zoewangg deleted the MarshallerRefactor branch February 3, 2018 00:33
aws-sdk-java-automation pushed a commit that referenced this pull request Feb 5, 2019
…47cefc16

Pull request: release <- staging/9e20f076-9332-4cde-9ef8-c28b47cefc16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants