[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1364?page=c...
]
Gonzalo Vasquez commented on HHH-1364:
--------------------------------------
Regarding:
"And as for non-cleared ThreadLocal-bound Sessions, this is the behavior I'd
want to see anyway since it indicates problems in your thread cleanup code."
Ok, I might have problems in my cleanup code, but how do I identify them? In my particular
case, the WebContainer (WAS 6) is the one which is "killing" unfinished threads
when I make hot-updates of the deployed EAR. When resuming application operation,
ConnectionManager doesn't come up gracefully, reporting the "connection manager
has been closed" message.
Any comments appreciated
Defensive check of isClosed when obtaining a connection from
ConnectionManager
------------------------------------------------------------------------------
Key: HHH-1364
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1364
Project: Hibernate3
Issue Type: Improvement
Components: core
Affects Versions: 3.1
Environment: Particularly bad in J2EE environments, where thread stale
thread-local connections show up in an unpredictable manner as threads are re-used.
Reporter: Damon Feldman
Assignee: Steve Ebersole
Priority: Minor
Fix For: 3.1.2
Original Estimate: 20 minutes
Remaining Estimate: 20 minutes
A null connection is returned to the caller, causing a NPE in another part of the system
if a connection is set to null AND the ConnectionManager is closed.
---- EXISTING CODE from ConnectionManager ----
/**
* Retrieves the connection currently managed by this ConnectionManager.
* <p/>
* Note, that we may need to obtain a connection to return here if a
* connection has either not yet been obtained (non-UserSuppliedConnectionProvider)
* or has previously been aggressively released (if supported in this environment).
*
* @return The current Connection.
*
* @throws HibernateException Indicates a connection is currently not
* available (we are currently manually disconnected).
*/
public Connection getConnection() throws HibernateException {
if ( connection == null && !isClosed ) {
openConnection();
}
return connection;
}
--------------------- RECOMMENDATION -----------
public Connection getConnection() throws HibernateException {
if ( connection == null) {
if(isClosed )
throw new HibernateException("A Connection Manager
that has been closed cannot supply a Connection.");
openConnection();
}
return connection;
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira