Skip to content

Commit 3fab199

Browse files
authored
Revert "Use standardized REST-JSON behavior (#2783)" (#2795)
This reverts commit a48c009.
1 parent fabd10e commit 3fab199

File tree

18 files changed

+67
-624
lines changed

18 files changed

+67
-624
lines changed

codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/ShapeModel.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,11 @@ public List<MemberModel> getUnboundMembers() {
187187
List<MemberModel> unboundMembers = new ArrayList<>();
188188
if (members != null) {
189189
for (MemberModel member : members) {
190-
if (member.getHttp().getLocation() == null && !member.getHttp().getIsPayload()) {
190+
if (member.getHttp().getLocation() == null) {
191191
if (hasPayloadMember) {
192-
// There is an explicit payload, but this unbound
193-
// member isn't it.
194-
// Note: Somewhat unintuitive, explicit payloads don't
195-
// have an explicit location; they're identified by
196-
// the payload HTTP trait being true.
197192
throw new IllegalStateException(String.format(
198-
"C2J Shape %s has both an explicit payload member and unbound (no explicit location) member, %s."
199-
+ " This is undefined behavior, verify the correctness of the C2J model.",
200-
c2jName, member.getName()));
193+
"C2J Shape %s has both an explicit payload member and unbound (no explicit location) members. "
194+
+ "This is undefined behavior, verify the correctness of the C2J model", c2jName));
201195
}
202196
unboundMembers.add(member);
203197
}
@@ -227,12 +221,7 @@ public List<MemberModel> getUnboundEventMembers() {
227221
public boolean hasPayloadMembers() {
228222
return hasPayloadMember ||
229223
getExplicitEventPayloadMember() != null ||
230-
hasImplicitPayloadMembers();
231-
232-
}
233-
234-
public boolean hasImplicitPayloadMembers() {
235-
return !getUnboundMembers().isEmpty() ||
224+
!getUnboundMembers().isEmpty() ||
236225
(isEvent() && !getUnboundEventMembers().isEmpty());
237226
}
238227

codegen/src/main/java/software/amazon/awssdk/codegen/poet/transform/protocols/JsonMarshallerSpec.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ protected FieldSpec operationInfoField() {
9595
.add(".httpMethod($T.$L)", SdkHttpMethod.class, shapeModel.getMarshaller().getVerb())
9696
.add(".hasExplicitPayloadMember($L)", shapeModel.isHasPayloadMember() ||
9797
shapeModel.getExplicitEventPayloadMember() != null)
98-
.add(".hasImplicitPayloadMembers($L)", shapeModel.hasImplicitPayloadMembers())
9998
.add(".hasPayloadMembers($L)", shapeModel.hasPayloadMembers());
10099

101100
if (StringUtils.isNotBlank(shapeModel.getMarshaller().getTarget())) {

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/alltypesrequestmarshaller.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
@SdkInternalApi
2020
public class AllTypesRequestMarshaller implements Marshaller<AllTypesRequest> {
2121
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().requestUri("/")
22-
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasImplicitPayloadMembers(true)
23-
.hasPayloadMembers(true).build();
22+
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasPayloadMembers(true).build();
2423

2524
private final BaseAwsJsonProtocolFactory protocolFactory;
2625

@@ -33,10 +32,11 @@ public SdkHttpFullRequest marshall(AllTypesRequest allTypesRequest) {
3332
Validate.paramNotNull(allTypesRequest, "allTypesRequest");
3433
try {
3534
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
36-
.createProtocolMarshaller(SDK_OPERATION_BINDING);
35+
.createProtocolMarshaller(SDK_OPERATION_BINDING);
3736
return protocolMarshaller.marshall(allTypesRequest);
3837
} catch (Exception e) {
3938
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
4039
}
4140
}
4241
}
42+

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/eventstreamoperationrequestmarshaller.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
@SdkInternalApi
2020
public class EventStreamOperationRequestMarshaller implements Marshaller<EventStreamOperationRequest> {
2121
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder()
22-
.requestUri("/2016-03-11/eventStreamOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(true)
23-
.hasImplicitPayloadMembers(false).hasPayloadMembers(true).hasEventStreamingInput(true).build();
22+
.requestUri("/2016-03-11/eventStreamOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(true)
23+
.hasPayloadMembers(true).hasEventStreamingInput(true).build();
2424

2525
private final BaseAwsJsonProtocolFactory protocolFactory;
2626

@@ -33,7 +33,7 @@ public SdkHttpFullRequest marshall(EventStreamOperationRequest eventStreamOperat
3333
Validate.paramNotNull(eventStreamOperationRequest, "eventStreamOperationRequest");
3434
try {
3535
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
36-
.createProtocolMarshaller(SDK_OPERATION_BINDING);
36+
.createProtocolMarshaller(SDK_OPERATION_BINDING);
3737
return protocolMarshaller.marshall(eventStreamOperationRequest);
3838
} catch (Exception e) {
3939
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/eventstreamoperationwithonlyinputrequestmarshaller.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
*/
1818
@Generated("software.amazon.awssdk:codegen")
1919
@SdkInternalApi
20-
public class EventStreamOperationWithOnlyInputRequestMarshaller implements Marshaller<EventStreamOperationWithOnlyInputRequest> {
20+
public class EventStreamOperationWithOnlyInputRequestMarshaller implements
21+
Marshaller<EventStreamOperationWithOnlyInputRequest> {
2122
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder()
22-
.requestUri("/2016-03-11/EventStreamOperationWithOnlyInput").httpMethod(SdkHttpMethod.POST)
23-
.hasExplicitPayloadMember(false).hasImplicitPayloadMembers(true).hasPayloadMembers(true).hasEventStreamingInput(true)
24-
.build();
23+
.requestUri("/2016-03-11/EventStreamOperationWithOnlyInput").httpMethod(SdkHttpMethod.POST)
24+
.hasExplicitPayloadMember(false).hasPayloadMembers(true).hasEventStreamingInput(true).build();
2525

2626
private final BaseAwsJsonProtocolFactory protocolFactory;
2727

@@ -34,10 +34,11 @@ public SdkHttpFullRequest marshall(EventStreamOperationWithOnlyInputRequest even
3434
Validate.paramNotNull(eventStreamOperationWithOnlyInputRequest, "eventStreamOperationWithOnlyInputRequest");
3535
try {
3636
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
37-
.createProtocolMarshaller(SDK_OPERATION_BINDING);
37+
.createProtocolMarshaller(SDK_OPERATION_BINDING);
3838
return protocolMarshaller.marshall(eventStreamOperationWithOnlyInputRequest);
3939
} catch (Exception e) {
4040
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
4141
}
4242
}
4343
}
44+

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/nestedcontainersrequestmarshaller.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
@SdkInternalApi
2020
public class NestedContainersRequestMarshaller implements Marshaller<NestedContainersRequest> {
2121
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().requestUri("/")
22-
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasImplicitPayloadMembers(true)
23-
.hasPayloadMembers(true).build();
22+
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasPayloadMembers(true).build();
2423

2524
private final BaseAwsJsonProtocolFactory protocolFactory;
2625

@@ -33,10 +32,11 @@ public SdkHttpFullRequest marshall(NestedContainersRequest nestedContainersReque
3332
Validate.paramNotNull(nestedContainersRequest, "nestedContainersRequest");
3433
try {
3534
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
36-
.createProtocolMarshaller(SDK_OPERATION_BINDING);
35+
.createProtocolMarshaller(SDK_OPERATION_BINDING);
3736
return protocolMarshaller.marshall(nestedContainersRequest);
3837
} catch (Exception e) {
3938
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
4039
}
4140
}
4241
}
42+

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/operationwithnoinputoroutputrequestmarshaller.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
*/
1818
@Generated("software.amazon.awssdk:codegen")
1919
@SdkInternalApi
20-
public class OperationWithNoInputOrOutputRequestMarshaller implements Marshaller<OperationWithNoInputOrOutputRequest> {
20+
public class OperationWithNoInputOrOutputRequestMarshaller implements
21+
Marshaller<OperationWithNoInputOrOutputRequest> {
2122
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().requestUri("/")
22-
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasImplicitPayloadMembers(false)
23-
.hasPayloadMembers(false).build();
23+
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasPayloadMembers(false).build();
2424

2525
private final BaseAwsJsonProtocolFactory protocolFactory;
2626

@@ -33,10 +33,11 @@ public SdkHttpFullRequest marshall(OperationWithNoInputOrOutputRequest operation
3333
Validate.paramNotNull(operationWithNoInputOrOutputRequest, "operationWithNoInputOrOutputRequest");
3434
try {
3535
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
36-
.createProtocolMarshaller(SDK_OPERATION_BINDING);
36+
.createProtocolMarshaller(SDK_OPERATION_BINDING);
3737
return protocolMarshaller.marshall(operationWithNoInputOrOutputRequest);
3838
} catch (Exception e) {
3939
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
4040
}
4141
}
4242
}
43+

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/streaminginputoperationrequestmarshaller.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
@SdkInternalApi
2020
public class StreamingInputOperationRequestMarshaller implements Marshaller<StreamingInputOperationRequest> {
2121
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder()
22-
.requestUri("/2016-03-11/streamingInputOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(true)
23-
.hasImplicitPayloadMembers(false).hasPayloadMembers(true).hasStreamingInput(true).build();
22+
.requestUri("/2016-03-11/streamingInputOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(true)
23+
.hasPayloadMembers(true).hasStreamingInput(true).build();
2424

2525
private final BaseAwsJsonProtocolFactory protocolFactory;
2626

@@ -33,10 +33,11 @@ public SdkHttpFullRequest marshall(StreamingInputOperationRequest streamingInput
3333
Validate.paramNotNull(streamingInputOperationRequest, "streamingInputOperationRequest");
3434
try {
3535
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
36-
.createProtocolMarshaller(SDK_OPERATION_BINDING);
36+
.createProtocolMarshaller(SDK_OPERATION_BINDING);
3737
return protocolMarshaller.marshall(streamingInputOperationRequest);
3838
} catch (Exception e) {
3939
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
4040
}
4141
}
4242
}
43+

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/streamingoutputoperationrequestmarshaller.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
@SdkInternalApi
2020
public class StreamingOutputOperationRequestMarshaller implements Marshaller<StreamingOutputOperationRequest> {
2121
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder()
22-
.requestUri("/2016-03-11/streamingOutputOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false)
23-
.hasImplicitPayloadMembers(false).hasPayloadMembers(false).build();
22+
.requestUri("/2016-03-11/streamingOutputOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false)
23+
.hasPayloadMembers(false).build();
2424

2525
private final BaseAwsJsonProtocolFactory protocolFactory;
2626

@@ -33,10 +33,11 @@ public SdkHttpFullRequest marshall(StreamingOutputOperationRequest streamingOutp
3333
Validate.paramNotNull(streamingOutputOperationRequest, "streamingOutputOperationRequest");
3434
try {
3535
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
36-
.createProtocolMarshaller(SDK_OPERATION_BINDING);
36+
.createProtocolMarshaller(SDK_OPERATION_BINDING);
3737
return protocolMarshaller.marshall(streamingOutputOperationRequest);
3838
} catch (Exception e) {
3939
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
4040
}
4141
}
4242
}
43+

core/protocols/aws-json-protocol/src/main/java/software/amazon/awssdk/protocols/json/DefaultJsonContentTypeResolver.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424
@SdkProtectedApi
2525
public class DefaultJsonContentTypeResolver implements JsonContentTypeResolver {
26-
private static final String REST_JSON_CONTENT_TYPE = "application/json";
2726

2827
private final String prefix;
2928

@@ -33,9 +32,7 @@ public DefaultJsonContentTypeResolver(String prefix) {
3332

3433
@Override
3534
public String resolveContentType(AwsJsonProtocolMetadata protocolMetadata) {
36-
if (AwsJsonProtocol.REST_JSON.equals(protocolMetadata.protocol())) {
37-
return REST_JSON_CONTENT_TYPE;
38-
}
35+
//Changing this to 'application/json' may break clients expecting 'application/x-amz-json-1.1'
3936
return prefix + protocolMetadata.protocolVersion();
4037
}
4138
}

0 commit comments

Comments
 (0)