Skip to content
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

GreengrassException builder returns exception of a wrong type #5662

Open
1 task
Illapikov opened this issue Oct 11, 2024 · 0 comments
Open
1 task

GreengrassException builder returns exception of a wrong type #5662

Illapikov opened this issue Oct 11, 2024 · 0 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@Illapikov
Copy link

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

@Illapikov Illapikov added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant