-
Notifications
You must be signed in to change notification settings - Fork 954
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
CC-1366: close ResultSets and Statements during shutdown #351
Conversation
It looks like @rayokota hasn't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here. Once you've signed reply with Appreciation of efforts, clabot |
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.
Thanks for the PR, @rayokota. Just one comment below, but otherwise looks great.
resetAndRequeueHead(querier); | ||
return null; | ||
} catch (Exception e) { |
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.
Maybe Throwable
?
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.
Yes, probably safer to catch Throwable here. I'll change it. Thanks for the review!
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.
One stylistic comment to keep in mind. Thanks!
@@ -243,14 +243,21 @@ public void stop() throws ConnectException { | |||
|
|||
log.debug("Returning {} records for {}", results.size(), querier.toString()); | |||
return results; | |||
} catch (SQLException e) { | |||
log.error("Failed to run query for table {}: {}", querier.toString(), e); | |||
} catch (SQLException sqle) { |
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.
nit: As I mentioned recently on another PR, we don't tend to name exception object with acronyms in the connectors. That's a stylistic comment to let you know what's the current trend. Up to you.
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.
Ok, thanks! It looks like this would need to change across the board in this connector, as sqle
is used pervasively. I'll leave it like this for now.
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.
I mentioned because the diff indicates otherwise, at least at this location.
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.
LGTM!
I went through the code to find possible places where a ResultSet might not be closed. The only case seems to be in poll(), when either an exception occurs or the task is shutdown. According to https://stackoverflow.com/questions/4507440/must-jdbc-resultsets-and-statements-be-closed-separately-although-the-connection, ResultSets should be closed even if the Connection is subsequently closed. Again, this seems to be the only place where a ResultSet could go unclosed.