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

fix: unwrap CompletionException in default client, rethrow as S3Encry… #162

Merged
merged 4 commits into from
May 30, 2023

Conversation

kessplas
Copy link
Contributor

…ptionClientException

Issue #, if available: #160

Description of changes: The "default" (non-async) S3 Encryption Client implementation is to block on the async API. In all of the operations (except getObject), the client does not unwrap the CompletionException which the async API wraps any failure with. The default API is expected to not be async, so it should not throw CompletionException. Furthermore, S3EC v3 moves to wrapping exceptions in S3EncryptionClientException (and its subclasses) so the correct behavior is to unwrap CompletionException and rethrow the actual exception wrapped in S3EncryptionClientException.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Check any applicable:

  • Were any files moved? Moving files changes their URL, which breaks all hyperlinks to the files.

@kessplas kessplas requested a review from a team as a code owner May 25, 2023 21:41
} catch (CompletionException e) {
throw new S3EncryptionClientException(e.getCause().getMessage(), e.getCause());
} catch (Exception e) {
throw new S3EncryptionClientException("Unable to delete objects.", e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the error message here is wrong for this method createMultipartUpload. Instead, we should be throwing e.getMessage().

} catch (CompletionException e) {
throw new S3EncryptionClientException(e.getCause().getMessage(), e.getCause());
} catch (Exception e) {
throw new S3EncryptionClientException("Unable to delete objects.", e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, the error message here is wrong for this method uploadPart. Instead, we should be throwing e.getMessage().

} catch (CompletionException e) {
throw new S3EncryptionClientException(e.getCause().getMessage(), e.getCause());
} catch (Exception e) {
throw new S3EncryptionClientException("Unable to delete objects.", e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, the error message here is wrong for this method completeMultipartUpload. Instead, we should be throwing e.getMessage().

Copy link
Contributor

@imabhichow imabhichow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kessplas kessplas merged commit 1a00d3e into main May 30, 2023
@kessplas kessplas deleted the exception-fix branch May 31, 2023 19:14
aws-crypto-tools-ci-bot pushed a commit that referenced this pull request Jun 1, 2023
### [3.0.1](v3.0.0...v3.0.1) (2023-06-01)

### Maintenance

* add metadata downgrade tests([#55](#55)) ([0fed900](0fed900))
* fix some issues with release ([#156](#156)) ([c6b4e64](c6b4e64))

### Fixes

* null check for InputStream in ApiNameVersion ([#161](#161)) ([c23aeb2](c23aeb2))
* unwrap CompletionException in default client, rethrow as S3Encry… ([#162](#162)) ([1a00d3e](1a00d3e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants