paul-rogers commented on code in PR #13196:
URL: https://github.com/apache/druid/pull/13196#discussion_r993885049
##########
sql/src/main/java/org/apache/druid/sql/avatica/DruidMeta.java:
##########
@@ -95,7 +97,12 @@ public static <T extends Throwable> T logFailure(T error,
String message, Object
*/
public static <T extends Throwable> T logFailure(T error)
{
- logFailure(error, error.getMessage());
+ if (error instanceof NoSuchConnectionException) {
Review Comment:
The reason is that Avatica itself handles this exception specially in
`AbstractHandler`. Avatica maps this exception to a specific error code. It
would be nice if this were a subclass of some Avatica base exception, but it
isn't.
We catch `NoSuchConnectionException` so we can exclude it from
`mapException(.)`. `mapException(.)` is a rough-and-ready way to clean up
exceptions. Looking at this more closely, it seems we have to guess where to
catch `NoSuchConnectionException`. In some places, we guessed wrong: catching
it when it can never be thrown. So, a better solution is to let
`mapException(.)` special-case the Avatica exceptions, rather than trying to
guess where these exceptions might be thrown and handling them in individual
`catch` clauses.
Looking at `AbstractHandler`, it seems we should be throwing
`AvaticaRuntimeException`s in our JDBC code so we can attach the preferred
`SqlState`, `Severity` and `ErrorCode`. I'll make a note of this and tackle it
in a later PR. This use of `AvaticaRuntimeException` parallels the discussion
we've had about the proposed `DruidException`.
While doing the above, I noticed that we catch the checked Avatica exception
`NoSuchStatementException` when we don't need to. I'm not sure why IntelliJ
inspections didn't complain. Fixed these also.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]