-
Notifications
You must be signed in to change notification settings - Fork 138
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
[Feature/multi_tenancy] Restore original exception handling expectations #2507
[Feature/multi_tenancy] Restore original exception handling expectations #2507
Conversation
6f20123
to
9ddfe16
Compare
Signed-off-by: Daniel Widdis <[email protected]>
9ddfe16
to
22a0ce5
Compare
@@ -114,7 +124,12 @@ default DeleteDataObjectResponse deleteDataObject(DeleteDataObjectRequest reques | |||
if (cause instanceof InterruptedException) { | |||
Thread.currentThread().interrupt(); | |||
} | |||
throw new OpenSearchException(cause); | |||
// Rethrow unchecked Exceptions | |||
if (cause instanceof RuntimeException) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about other Exceptions like: IllegalArgumentException
, IOException
, MLException
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IllegalArgumentException
and MLException
are both subclasses of RuntimeException
so will be thrown here as the original exception.
IOException
is a checked exception so is wrapped in an unchecked exception before throwing.
See the PR description where I suggested possibly wrapping in an UndeclaredThrowableException
instead of OpenSearchException
.
Do you have an alternative proposal here? If we don't rethrow checked exceptions we need to add throws
clauses to every one of these API methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have MLException class, may be we can re-use them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These clients aren't unique to ML Commons. The exceptions should be generic. This class will not be in ML Commons eventually and shouldn't need to add it as a dependency.
The intent here is to rethrow the original exception whenever possible, and if not, pass a throwable with the original exception as its cause.
// Rethrow unchecked Exceptions | ||
if (cause instanceof RuntimeException) { | ||
throw (RuntimeException) cause; | ||
} else { | ||
throw new OpenSearchException(cause); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that CompletionException extends RunTimeException do we except non-RunTimeException?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we "expect"? No. But I spent quite some time debugging a mysterious NullPointerException which was swallowed without handling like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I've already extracted the cause from the Completion Exception:
Throwable cause = e.getCause();
closing this PR in favor of #2520 |
Description
Restores the original exception handling behavior for connector transport actions
Issues Resolved
Resolves TODO from #2459
Open question: should the non-runtime exceptions be wrapped in an
UndeclaredThrowableException
rather than anOpenSearchStatusException
? I'm thinking probably.Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.