You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Don Brown (JIRA)" <ji...@apache.org> on 2006/04/25 20:56:45 UTC
[jira] Reopened: (STR-200) Connection Pool does not handle stale
(closed) connections
[ http://issues.apache.org/struts/browse/STR-200?page=all ]
Don Brown reopened STR-200:
---------------------------
> Connection Pool does not handle stale (closed) connections
> ----------------------------------------------------------
>
> Key: STR-200
> URL: http://issues.apache.org/struts/browse/STR-200
> Project: Struts Action 1
> Type: Bug
> Components: Action
> Versions: 1.0 Beta 2
> Environment: Operating System: other
> Platform: Sun
> Reporter: hnguyen
> Assignee: Craig McClanahan
> Fix For: 1.0.0
>
> Struts connection pool implemented in GenericDataSource.java does not handle
> stale connections.
> Stale connections are connections having been closed by the database. This
> could be due to no activity timeout (such as wait_timeout in mysql) or the
> database was down and up again. Currently when returning a pool connection to
> a caller in getConnection(), Struts does not check if the real database
> connection of that pool connection has been closed or not.
> Below is my patch for this problem in the GenericDataSource.java, revision 1.5
> *** GenericDataSource.java.r1.5 Wed May 23 17:44:12 2001
> --- GenericDataSource.java.r1.5fixed Wed May 23 17:31:07 2001
> ***************
> *** 402,414 ****
>
> // Return an existing connection from the pool if there is one
> synchronized (connections) {
> ! if (!connections.isEmpty()) {
> ! useCount++;
> GenericConnection connection = (GenericConnection)
> connections.removeFirst();
> // unclose the connection's wrapper
> connection.setClosed(false);
> return(connection);
> ! // return ((Connection) connections.removeFirst()); DEBUG
> }
> }
>
> --- 402,425 ----
>
> // Return an existing connection from the pool if there is one
> synchronized (connections) {
> ! while (!connections.isEmpty()) {
> GenericConnection connection = (GenericConnection)
> connections.removeFirst();
> + // Checking for stale connection. Stale connections are
> connections
> + // closed by the database. This could be due to no
> activity
> + // timeout (such as mysql wait_timeout) or the database
> was down
> + // and up again.
> + if (connection.getConnection().isClosed())
> + {
> + activeCount --;
> + connection = null;
> + continue;
> + }
> + else {
> // unclose the connection's wrapper
> + useCount++;
> connection.setClosed(false);
> return(connection);
> ! }
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org