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

Use a simple class to sanitize JDBC exceptions and also log them #11843

Merged

Conversation

TSFenwick
Copy link
Contributor

add a class to sanitize JDBC related exceptions and also log them
added a simple test that tests out that the exception gets sanitized

Description

Created a simple class to handle logging errors and sanitizing them. This is to be able to sanitize JDBC exceptions.

explored two others ways of solving this.

  1. Wrap all the public DruidMeta methods in a try catch to sanitize all the JDBC exceptions.
  2. Pass a function to handle sanitizing and logging exceptions instead of using a simple class to handle the exceptions.

also added @NonNull annotation for ErrorResponseTransformStrategy in ServerConfig's constructor.


Key changed/added classes in this PR
  • ErrorHandler

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • been tested in a test Druid cluster.

The purpose of this is to sanitize JDBC errors, but can sanitize other errors
if they implement SanitizableError Interface

add a class to log errors and sanitize them
added a simple test that tests out that the error gets sanitized
add @nonnull annotation to serverconfig's ErrorResponseTransfromStrategy
…only log specific details

This is so an end user gets relevant information but not too much info since they might now how
many brokers they have
Copy link
Contributor

@maytasm maytasm left a comment

Choose a reason for hiding this comment

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

Are all the exceptions that can be thrown by JDBC implements SanitizableException?

@paul-rogers
Copy link
Contributor

paul-rogers commented Oct 29, 2021

Thanks for the contribution. Having good, clean user error messages is great. Even better if they tell the user what's wrong so they know what to do to fix the issue. (SQL error, missing column, unsupported operation, or whatever.)

On the other hand, it is vital that us developers be able to see the error. So, the original, unvarnished, detailed call stack, in all its gory detail, should be logged at some log level.

Example, I make a change an introduce an accidental NPE in my branch. A test fails. I have to be able to see the stack trace to figure out what I botched up so I can fix it.

Does this solution include that logging aspect?

Edit: checked with the @TSFenwick, turns out we do log the errors, so this aspect is all good.

added new error types that need to be sanitized
also sanitize deprecated and unsupported exceptions.
add docs
avoid blanket turning all exceptions into runtime exceptions
docs/configuration/index.md Outdated Show resolved Hide resolved
docs/configuration/index.md Outdated Show resolved Hide resolved
@suneet-s
Copy link
Contributor

suneet-s commented Nov 2, 2021

ugh Travis.... why won't you run!

@suneet-s suneet-s closed this Nov 2, 2021
@suneet-s suneet-s reopened this Nov 2, 2021
add more javadocs
add support UOE sanitization
@suneet-s suneet-s closed this Nov 2, 2021
@suneet-s suneet-s reopened this Nov 2, 2021
clean up bad formatting and commented code. add missed catch for NoSuchStatementException
clean up comments for error handler and add comment explainging not wanting to santize avatica exceptions
@suneet-s suneet-s merged commit 1487f55 into apache:master Nov 16, 2021
@abhishekagarwal87 abhishekagarwal87 added this to the 0.23.0 milestone May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants