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

CC-1366: close ResultSets and Statements during shutdown #351

Merged
merged 2 commits into from
Jan 26, 2018

Conversation

rayokota
Copy link
Member

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.

@ghost
Copy link

ghost commented Jan 23, 2018

It looks like @rayokota hasn't signed our Contributor License Agreement, yet.

The purpose of a CLA is to ensure that the guardian of a project's outputs has the necessary ownership or grants of rights over all contributions to allow them to distribute under the chosen licence.
Wikipedia

You can read and sign our full Contributor License Agreement here.

Once you've signed reply with [clabot:check] to prove it.

Appreciation of efforts,

clabot

Copy link
Member

@rhauch rhauch left a 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) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe Throwable?

Copy link
Member Author

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!

Copy link
Member

@kkonstantine kkonstantine left a 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) {
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

LGTM!

@rayokota rayokota merged commit b7b8734 into confluentinc:4.0.x Jan 26, 2018
@rayokota rayokota deleted the 4.0.x branch January 26, 2018 18:21
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.

None yet

3 participants