[
https://issues.apache.org/jira/browse/DERBY-2532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12650927#action_12650927
]
Sabari S Kumar commented on DERBY-2532:
---------------------------------------
as per the sourcecode of ClientXAConnection,
a close() call will call its super.close().
ie,the close() of ClientPooledConnection class.
now in CPC's close(),we check if the connection is
already closed in the log and only if the
connection is not closed already,it attempts to
close the connection.Else it simply returns.
So there is no scope of an SQL exception as
stated in 2532.
Now if its required that there shud be an SQLEx
raised,we can simply do that by forcing an SQLEx
using the 'throw' keyword, instead of returning normally.
The current implementation of close function is
as follows:
public synchronized void close() throws SQLException JavaDoc {
150 try
151 {
152 if (logWriter_ != null) {
153 logWriter_.traceEntry(this, "close");
154 }
155
156 if (logicalConnection_ != null) {
157 logicalConnection_.nullPhysicalConnection();
158 logicalConnection_ = null;
159 }
160
161 if (physicalConnection_ == null) {
162 return;
163 }
164
165 // Even if the physcial connection is marked closed (in the
pool),
166 // this will close its underlying resources.
167 physicalConnection_.closeResources();
168 }
169 finally
170 {
171 physicalConnection_ = null;
172 }
173 }
174
So a possible fix is:
add a snippet:
if(logicalConnection_ == null)
{
throw new SQLException("Connection already closed");
}
as shown:
public synchronized void close() throws SQLException JavaDoc {
150 try
151 {
152 if (logWriter_ != null) {
153 logWriter_.traceEntry(this, "close");
154 }
if(logicalConnection_ == null)
{
throw new SQLException("Connection already closed");
}
155
156 if (logicalConnection_ != null) {
157 logicalConnection_.nullPhysicalConnection();
158 logicalConnection_ = null;
159 }
160
161 if (physicalConnection_ == null) {
162 return;
163 }
164
165 // Even if the physcial connection is marked closed (in the
pool),
166 // this will close its underlying resources.
167 physicalConnection_.closeResources();
168 }
169 finally
170 {
171 physicalConnection_ = null;
172 }
173 }
174
> Client does not return SQLException on XAConnection.getXAResource() on a
> closed connection, Embedded does
> ---------------------------------------------------------------------------------------------------------
>
> Key: DERBY-2532
> URL: https://issues.apache.org/jira/browse/DERBY-2532
> Project: Derby
> Issue Type: Bug
> Components: Network Client
> Affects Versions: 10.3.1.4
> Reporter: Myrna van Lunteren
> Assignee: Sabari S Kumar
>
> In the following scenario from converted test DataSourceTest:
> (non-tested code based on the test code)
> ----------------
> ClientXADataSource dsx = new ClientXADataSource();
> dsx.setDatabaseName("tstdb");
> XAConnection xac = dsx.getXAConnection();
> XAConnection xac2 = dsx.getXAConnection();
> XAResource xar2 = xac2.getXAResource();
> xac2.close();
> // allow close on already closed XAConnection
> xac2.close();
> try {
> xac2.getXAResource();
> // Network Server does not think this is worth an exception.
> } catch (SQLException sqle) {
> System.out.println("expect a 08003 as with Embedded");
> }
> ------------------
> With DerbyNetClient, the xac2.getXAResource() does not return an SQLException.
> This ought to be documented if expected, or fixed.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.