You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2003/07/21 00:07:57 UTC
DO NOT REPLY [Bug 21748] New: -
BasicDataSource.close() throws NPE
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21748>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21748
BasicDataSource.close() throws NPE
Summary: BasicDataSource.close() throws NPE
Product: Commons
Version: 1.0 Final
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: Other
Component: Dbcp
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: aaron.knauf@vodafone.co.nz
If a BasicDataSource is closed without having been used, the connectionPool
will not have been initialised and a NPE will be thrown in line 486.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
RE: DO NOT REPLY [Bug 21748] New: - BasicDataSource.close() throws NPE
Posted by "Noel J. Bergman" <no...@devtech.com>.
This is an easy fix, but since it would be my first commit to this project,
I just want to see what the group preference is. The basic problem is this:
public void close() throws SQLException {
GenericObjectPool oldpool = connectionPool;
connectionPool = null;
dataSource = null;
try {
----> oldpool.close();
} catch(SQLException e) {
throw e;
} catch(RuntimeException e) {
throw e;
} catch(Exception e) {
throw new SQLException(e.toString());
}
}
The oldpool variable is null, and unlike other places in the code, there is
no check. The minimal change would be to change that one line by adding an
if check. My preference would be to follow the pattern is used elsewhere in
the code for checking. So the final code would be:
public void close() throws SQLException {
dataSource = null;
if (connectionPool != null) {
GenericObjectPool oldpool = connectionPool;
connectionPool = null;
try {
oldpool.close();
} catch(SQLException e) {
throw e;
} catch(RuntimeException e) {
throw e;
} catch(Exception e) {
throw new SQLException(e.toString());
}
}
}
Any objections?
--- Noel
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org