-
Notifications
You must be signed in to change notification settings - Fork 914
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
Conversation
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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....
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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. ¯_(ツ)_/¯
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
e42a39d
to
61af631
Compare
61af631
to
8f76ce3
Compare
…47cefc16 Pull request: release <- staging/9e20f076-9332-4cde-9ef8-c28b47cefc16
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:
Marshaller Refactor
a. Json, rest-json marshaller
b. query xml, rest-xml, ec2 marshaller
c. api gateway marshaller
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
Testing
mvn clean install
and integration testScreenshots (if appropriate)
Types of changes
Checklist
mvn install
succeedsLicense