You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/06/24 19:55:22 UTC
svn commit: r201658 -
/incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.jcs
Author: ekoneil
Date: Fri Jun 24 10:55:20 2005
New Revision: 201658
URL: http://svn.apache.org/viewcvs?rev=201658&view=rev
Log:
Fix for BEEHIVE-834 from Chad Schoettger.
The JDBC control was NPE'ing after serialization and now has a private method to lazily instantiate an object used to store resources that need to be closed in onRelease().
BB: self
DRT: Beehive pass
Modified:
incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.jcs
Modified: incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.jcs
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.jcs?rev=201658&r1=201657&r2=201658&view=diff
==============================================================================
--- incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.jcs (original)
+++ incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.jcs Fri Jun 24 10:55:20 2005
@@ -65,8 +65,8 @@
protected transient DataSource _dataSource;
protected transient ConnectionDriver _connectionDriver;
- private transient Calendar _cal;
- private transient Vector<PreparedStatement> _resources = new Vector<PreparedStatement>();
+ private Calendar _cal;
+ private transient Vector<PreparedStatement> _resources;
private static final String EMPTY_STRING = "";
private static final Logger logger = Logger.getLogger(JdbcControlImpl.class);
@@ -123,13 +123,13 @@
logger.debug("Enter: onRelease()");
}
- for (PreparedStatement ps : _resources) {
+ for (PreparedStatement ps : getResources()) {
try {
ps.close();
} catch (SQLException sqe) {
}
}
- _resources.clear();
+ getResources().clear();
if (_connection != null) {
try {
@@ -364,7 +364,7 @@
returnObject = rsm.mapToResultType(_context, method, rs, _cal);
if (rsm.canCloseResultSet() == false) {
- _resources.add(ps);
+ getResources().add(ps);
}
//
@@ -383,7 +383,7 @@
} finally {
// Keep statements open that have in-use result sets
- if (ps != null && !_resources.contains(ps)) {
+ if (ps != null && !getResources().contains(ps)) {
ps.close();
}
}
@@ -453,6 +453,17 @@
throw new ControlException("Database driver class not found!", e);
}
return con;
+ }
+
+ /**
+ * Get the Vector of Statements which we need to keep open.
+ * @return Vector of PreparedStatement
+ */
+ private Vector<PreparedStatement> getResources() {
+ if (_resources == null) {
+ _resources = new Vector<PreparedStatement>();
+ }
+ return _resources;
}
/**