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

Closing a connection with "usageCount > 1" is actually possible. #21

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

rankinc
Copy link
Contributor

@rankinc rankinc commented Apr 1, 2014

JdbcPooledConnection.close() says:

// this should never happen, should we throw an exception or log at warn/error?
if (usageCount > 0) {
    log.warn("close connection with usage count > 0, " + this);
}

However, should JdbcPooledConnection.getConnectionHandle() throw an exception because (e.g.) testConnection() has failed, then usageCount will still have been incremented when XAPool.getConnectionHandle() tries to close the invalid connection.

…owever, it can happen if JdbcPooledConnection.getConnectionHandle() throws an exception - e.g. if testConnection() fails. So ensure that JdbcPooledConnection.getConnectionHandle() decrements usageCount again if it fails, and sets the connection's state to NOT_ACCESSIBLE.

This fix is currently only for "correctness" w.r.t. JdbcPooledConnection's documented semantics. The only visible effect is seeing fewer warnings in the log.
@rankinc
Copy link
Contributor Author

rankinc commented Apr 2, 2014

Could someone rerun this Travis CI build please? GitHub was having difficulty cloning repositories last night.

@rankinc
Copy link
Contributor Author

rankinc commented Apr 2, 2014

The build failure here is the same one that is fixed by the unit-test-jdk7 feature branch.

Conflicts:
	btm/src/main/java/bitronix/tm/resource/jdbc/JdbcPooledConnection.java
Conflicts:
	btm/src/main/java/bitronix/tm/resource/jdbc/JdbcPooledConnection.java
Fix references to XA states in comments, and remove unused import.
More final variables and @OverRide annotations.
Add generic types to List and Iterator.
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.

1 participant