Description
Describe the bug
Currently GreengrassException builder returns an object with incorrect type. It returns AwsServiceException
instead of GreengrassException
.
Which in turn forces unnecessary casting (GreengrassException) GreengrassException.builder().build()
and doesn't seem in line what other exceptions do.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
GreengrassException exception = GreengrassException.builder()
.message("not found")
.statusCode(404)
.build();
to compile without an error
Current Behavior
GreengrassException exception = GreengrassException.builder()
.message("not found")
.statusCode(404)
.build();
produces a compilation error
incompatible types: software.amazon.awssdk.awscore.exception.AwsServiceException cannot be converted to software.amazon.awssdk.services.greengrass.model.GreengrassException
Reproduction Steps
Given the actual behavior produces compilation error, the following code should be sufficient for reproduction:
GreengrassException exception = GreengrassException.builder()
.message("not found")
.statusCode(404)
.build();
Possible Solution
I don't have much experience with generated code, but looking at the BadRequestException
from the same package, there's a difference in Builder interfaces:
BadRequestException:
public interface Builder extends SdkPojo, CopyableBuilder<Builder, BadRequestException>, GreengrassException.Builder
vs
GreengrassException:
protected static class BuilderImpl extends AwsServiceException.BuilderImpl implements Builder
Note that BadRequestException
builder works correctly, when built it returns BadRequestException
and not GreengrassException
, the parent one.
After looking a bit deeper, CopyableBuilder
is what provides T build()
method, which makes BadRequestException
to return correct type.
Additional Information/Context
No response
AWS Java SDK version used
2.28.19
JDK version used
openjdk version "17.0.9" 2023-10-17 OpenJDK Runtime Environment (build 17.0.9+9-Ubuntu-120.04) OpenJDK 64-Bit Server VM (build 17.0.9+9-Ubuntu-120.04, mixed mode, sharing)
Operating System and version
Ubuntu 20.04.6 LTS