Skip to content

Update non-streaming error unmarshalling to use new mapping function #5991

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

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f80bfcf
Update non-streaming error unmarshalling to use new mapping function
S-Saranya1 Mar 25, 2025
9ab362d
Additional changes for update non-streaming error unmarshaller - Fixi…
S-Saranya1 Mar 26, 2025
43642d3
Added changelog
S-Saranya1 Mar 26, 2025
e0b6afe
Additional changes for update non-streaming error unmarshalling to us…
S-Saranya1 Mar 26, 2025
583d27e
Fixing errors
S-Saranya1 Mar 27, 2025
df221a2
Update query protocol error unmarshalling with new mapping function
S-Saranya1 Mar 31, 2025
d7c8e75
Additional changes for updating non-streaming error unmarshaller
S-Saranya1 Apr 2, 2025
6790682
Updating tests
S-Saranya1 Apr 2, 2025
8c8e751
Additional changes for updating non-streaming error unmarshaller
S-Saranya1 Apr 3, 2025
5b61216
Fixing checkstyle issues
S-Saranya1 Apr 4, 2025
859ca45
Fixing checkstyle issues
S-Saranya1 Apr 4, 2025
6079584
Fixing test failures
S-Saranya1 Apr 8, 2025
736e401
fixed typo (#6002)
Fred1155 Apr 9, 2025
f79236c
AWS Transfer Family Update: This launch includes 2 enhancements to SF…
Apr 9, 2025
549a9ae
AWS Glue Update: The TableOptimizer APIs in AWS Glue now return the D…
Apr 9, 2025
72529af
AWS Control Catalog Update: The GetControl API now surfaces a control…
Apr 9, 2025
e2ba8bb
AWS Ground Station Update: Support tagging Agents and adjust input fi…
Apr 9, 2025
3fd0675
Amazon DynamoDB Update: Documentation update for secondary indexes an…
Apr 9, 2025
df03e33
Updated endpoints.json and partitions.json.
Apr 9, 2025
9428f67
Release 2.31.19. Updated CHANGELOG.md, README.md and all pom.xml.
Apr 9, 2025
6685239
Update to next snapshot version: 2.31.20-SNAPSHOT
Apr 9, 2025
b5e4483
Additional changes for updating non-streaming error unmarshaller
S-Saranya1 Apr 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
42 changes: 42 additions & 0 deletions .changes/2.31.19.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "2.31.19",
"date": "2025-04-09",
"entries": [
{
"type": "feature",
"category": "AWS Control Catalog",
"contributor": "",
"description": "The GetControl API now surfaces a control's Severity, CreateTime, and Identifier for a control's Implementation. The ListControls API now surfaces a control's Behavior, Severity, CreateTime, and Identifier for a control's Implementation."
},
{
"type": "feature",
"category": "AWS Glue",
"contributor": "",
"description": "The TableOptimizer APIs in AWS Glue now return the DpuHours field in each TableOptimizerRun, providing clients visibility to the DPU-hours used for billing in managed Apache Iceberg table compaction optimization."
},
{
"type": "feature",
"category": "AWS Ground Station",
"contributor": "",
"description": "Support tagging Agents and adjust input field validations"
},
{
"type": "feature",
"category": "AWS Transfer Family",
"contributor": "",
"description": "This launch includes 2 enhancements to SFTP connectors user-experience: 1) Customers can self-serve concurrent connections setting for their connectors, and 2) Customers can discover the public host key of remote servers using their SFTP connectors."
},
{
"type": "feature",
"category": "Amazon DynamoDB",
"contributor": "",
"description": "Documentation update for secondary indexes and Create_Table."
},
{
"type": "feature",
"category": "AWS SDK for Java v2",
"contributor": "",
"description": "Updated endpoint and partition metadata."
}
]
}
6 changes: 6 additions & 0 deletions .changes/next-release/bugfix-AWSSDKforJavav2-e869e94.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "bugfix",
"category": "AWS SDK for Java v2",
"contributor": "",
"description": "Enhance non-streaming error unmarshalling to properly unmarshall exceptions to their expected types."
}
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
#### 👋 _Looking for changelogs for older versions? You can find them in the [changelogs](./changelogs) directory._
# __2.31.19__ __2025-04-09__
## __AWS Control Catalog__
- ### Features
- The GetControl API now surfaces a control's Severity, CreateTime, and Identifier for a control's Implementation. The ListControls API now surfaces a control's Behavior, Severity, CreateTime, and Identifier for a control's Implementation.

## __AWS Glue__
- ### Features
- The TableOptimizer APIs in AWS Glue now return the DpuHours field in each TableOptimizerRun, providing clients visibility to the DPU-hours used for billing in managed Apache Iceberg table compaction optimization.

## __AWS Ground Station__
- ### Features
- Support tagging Agents and adjust input field validations

## __AWS SDK for Java v2__
- ### Features
- Updated endpoint and partition metadata.

## __AWS Transfer Family__
- ### Features
- This launch includes 2 enhancements to SFTP connectors user-experience: 1) Customers can self-serve concurrent connections setting for their connectors, and 2) Customers can discover the public host key of remote servers using their SFTP connectors.

## __Amazon DynamoDB__
- ### Features
- Documentation update for secondary indexes and Create_Table.

# __2.31.18__ __2025-04-08__
## __AWS Cost Explorer Service__
- ### Features
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ To automatically manage module versions (currently all modules have the same ver
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.31.18</version>
<version>2.31.19</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -85,12 +85,12 @@ Alternatively you can add dependencies for the specific services you use only:
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ec2</artifactId>
<version>2.31.18</version>
<version>2.31.19</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
<version>2.31.18</version>
<version>2.31.19</version>
</dependency>
```

Expand All @@ -102,7 +102,7 @@ You can import the whole SDK into your project (includes *ALL* services). Please
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-sdk-java</artifactId>
<version>2.31.18</version>
<version>2.31.19</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion archetypes/archetype-app-quickstart/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>archetypes</artifactId>
<groupId>software.amazon.awssdk</groupId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion archetypes/archetype-lambda/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>archetypes</artifactId>
<groupId>software.amazon.awssdk</groupId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archetype-lambda</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archetypes/archetype-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>archetypes</artifactId>
<groupId>software.amazon.awssdk</groupId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion archetypes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>aws-sdk-java-pom</artifactId>
<groupId>software.amazon.awssdk</groupId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archetypes</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion aws-sdk-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<parent>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-sdk-java-pom</artifactId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>aws-sdk-java</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion bom-internal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>aws-sdk-java-pom</artifactId>
<groupId>software.amazon.awssdk</groupId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<parent>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-sdk-java-pom</artifactId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>bom</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion bundle-logging-bridge/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-sdk-java-pom</artifactId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
</parent>
<artifactId>bundle-logging-bridge</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion bundle-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-sdk-java-pom</artifactId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
</parent>
<artifactId>bundle-sdk</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-sdk-java-pom</artifactId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
</parent>
<artifactId>bundle</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion codegen-lite-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-sdk-java-pom</artifactId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>codegen-lite-maven-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion codegen-lite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-sdk-java-pom</artifactId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
</parent>
<artifactId>codegen-lite</artifactId>
<name>AWS Java SDK :: Code Generator Lite</name>
Expand Down
2 changes: 1 addition & 1 deletion codegen-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-sdk-java-pom</artifactId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>codegen-maven-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion codegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-sdk-java-pom</artifactId>
<version>2.31.19-SNAPSHOT</version>
<version>2.31.20-SNAPSHOT</version>
</parent>
<artifactId>codegen</artifactId>
<name>AWS Java SDK :: Code Generator</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import software.amazon.awssdk.codegen.model.intermediate.OperationModel;
import software.amazon.awssdk.codegen.model.intermediate.Protocol;
import software.amazon.awssdk.codegen.model.intermediate.ShapeModel;
import software.amazon.awssdk.codegen.model.intermediate.ShapeType;
import software.amazon.awssdk.codegen.poet.PoetExtension;
import software.amazon.awssdk.codegen.poet.auth.scheme.AuthSchemeSpecUtils;
import software.amazon.awssdk.codegen.poet.client.traits.HttpChecksumRequiredTrait;
Expand Down Expand Up @@ -116,7 +117,6 @@ public MethodSpec initProtocolFactory(IntermediateModel model) {
methodSpec.addCode("$L", hasAwsQueryCompatible());
}

registerModeledExceptions(model, poetExtensions).forEach(methodSpec::addCode);
methodSpec.addCode(";");

return methodSpec.build();
Expand Down Expand Up @@ -170,11 +170,40 @@ public CodeBlock responseHandler(IntermediateModel model, OperationModel opModel
public Optional<CodeBlock> errorResponseHandler(OperationModel opModel) {
String protocolFactory = protocolFactoryLiteral(model, opModel);

return Optional.of(
CodeBlock.builder()
.add("\n\n$T<$T> errorResponseHandler = createErrorResponseHandler($L, operationMetadata);",
HttpResponseHandler.class, AwsServiceException.class, protocolFactory)
.build());
CodeBlock.Builder builder = CodeBlock.builder();
ParameterizedTypeName metadataMapperType = ParameterizedTypeName.get(
ClassName.get(Function.class),
ClassName.get(String.class),
ParameterizedTypeName.get(Optional.class, ExceptionMetadata.class));

builder.add("\n$T exceptionMetadataMapper = errorCode -> {\n", metadataMapperType);
builder.add("if (errorCode == null) {\n");
builder.add("return $T.empty();\n", Optional.class);
builder.add("}\n");
builder.add("switch (errorCode) {\n");
model.getShapes().values().stream()
.filter(shape -> shape.getShapeType() == ShapeType.Exception)
.forEach(exceptionShape -> {
String exceptionName = exceptionShape.getShapeName();
String errorCode = exceptionShape.getErrorCode();

builder.add("case $S:\n", errorCode);
builder.add("return $T.of($T.builder()\n", Optional.class, ExceptionMetadata.class)
.add(".errorCode($S)\n", errorCode);
builder.add(populateHttpStatusCode(exceptionShape, model));
builder.add(".exceptionBuilderSupplier($T::builder)\n",
poetExtensions.getModelClassFromShape(exceptionShape))
.add(".build());\n");
});

builder.add("default: return $T.empty();\n", Optional.class);
builder.add("}\n");
builder.add("};\n");

builder.add("$T<$T> errorResponseHandler = createErrorResponseHandler($L, operationMetadata, exceptionMetadataMapper);",
HttpResponseHandler.class, AwsServiceException.class, protocolFactory);

return Optional.of(builder.build());
}

@Override
Expand Down Expand Up @@ -411,24 +440,8 @@ public Optional<MethodSpec> createErrorResponseHandler() {
ClassName httpResponseHandler = ClassName.get(HttpResponseHandler.class);
ClassName sdkBaseException = ClassName.get(AwsServiceException.class);
TypeName responseHandlerOfException = ParameterizedTypeName.get(httpResponseHandler, sdkBaseException);

return Optional.of(MethodSpec.methodBuilder("createErrorResponseHandler")
.addParameter(BaseAwsJsonProtocolFactory.class, "protocolFactory")
.addParameter(JsonOperationMetadata.class, "operationMetadata")
.returns(responseHandlerOfException)
.addModifiers(Modifier.PRIVATE)
.addStatement("return protocolFactory.createErrorResponseHandler(operationMetadata)")
.build());
}

@Override
public Optional<MethodSpec> createEventstreamErrorResponseHandler() {
ClassName httpResponseHandler = ClassName.get(HttpResponseHandler.class);
ClassName sdkBaseException = ClassName.get(AwsServiceException.class);
TypeName responseHandlerOfException = ParameterizedTypeName.get(httpResponseHandler, sdkBaseException);
ParameterizedTypeName mapperType = ParameterizedTypeName.get(ClassName.get(Function.class),
ClassName.get(String.class), ParameterizedTypeName.get(Optional.class, ExceptionMetadata.class));

return Optional.of(MethodSpec.methodBuilder("createErrorResponseHandler")
.addParameter(BaseAwsJsonProtocolFactory.class, "protocolFactory")
.addParameter(JsonOperationMetadata.class, "operationMetadata")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,4 @@ public CodeBlock asyncExecutionHandler(IntermediateModel intermediateModel, Oper
public Optional<MethodSpec> createErrorResponseHandler() {
return Optional.empty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public CodeBlock responseHandler(IntermediateModel model,
return CodeBlock.builder()
.addStatement("\n\n$T responseHandler = protocolFactory.createCombinedResponseHandler($T::builder, "
+ "new $T().withHasStreamingSuccessResponse($L))",
handlerType, responseType, XmlOperationMetadata.class, opModel.hasStreamingOutput())
handlerType, responseType, XmlOperationMetadata.class, opModel.hasStreamingOutput())
.build();
}

Expand Down Expand Up @@ -386,4 +386,4 @@ private CodeBlock whenCompleteBlock(OperationModel operationModel, String respon

return whenComplete.build();
}
}
}
Loading
Loading