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

Translate S3Exception for headObject and headBucket #830

Merged
merged 1 commit into from
Nov 30, 2018

Conversation

zoewangg
Copy link
Contributor

@zoewangg zoewangg commented Nov 16, 2018

  • Translate S3Exception for headObject and headBucket via interceptor
    Throw NoSuchKey exception for headObject and NoSuchBucket exception for headBucket for 404 status code.

  • Added modifyException interceptor method

All S3 integration tests passed

try {
Context.FailedExecution failedContext =
new DefaultFailedExecutionContext(context.executionContext().interceptorContext(), failure);
context.interceptorChain().onExecutionFailure(failedContext, context.executionAttributes());
} catch (SdkServiceException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we go all-out and propagate SdkException? All of the exceptions? Do we have similar behavior for the other on* methods, that suppresses exceptions that are thrown?

Copy link
Contributor

Choose a reason for hiding this comment

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

The swallowing behavior is only onExecuteFailure since at this point there's already an Exception thrown higher up. The other on* methods let the exception propagate

@Test
public void test() {
if (hook != Hook.ON_EXECUTION_FAILURE) {
doVerify(() -> clientHandler.execute(executionParams), (t) -> t.getCause().getCause().getMessage().equals(hook.name()));
} else {
// ON_EXECUTION_FAILURE is handled differently because we don't
// want an exception thrown from the interceptor to replace the
// original exception.
doVerify(() -> clientHandler.execute(executionParams),
(t) -> {
for (; t != null; t = t.getCause()) {
if (Hook.ON_EXECUTION_FAILURE.name().equals(t.getMessage())) {
return false;
}
}
return true;
});
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm fine with propagating SdkException. @shorea Do you have any concerns?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add another interceptor method that lets you modify the exception so you don't have to throw?

Copy link
Contributor

Choose a reason for hiding this comment

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

Andrew coming in with the BIG ideas. I like it!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added modifyException interceptor method.


/**
* Translate S3Exception for the API calls that do not contain the detailed error code.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Long-term, should we push these upstream to s3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we should.

@zoewangg zoewangg force-pushed the zoewang-s3ExceptionTranslation branch 2 times, most recently from 3f78b16 to d26f697 Compare November 20, 2018 23:23
@zoewangg zoewangg force-pushed the zoewang-s3ExceptionTranslation branch 2 times, most recently from 859a8a7 to aba3121 Compare November 30, 2018 07:18
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.

4 participants