db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r951346 - in /db/derby/code/trunk/java: client/org/apache/derby/client/ClientXAConnection.java testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
Date Fri, 04 Jun 2010 09:49:30 GMT
Author: kristwaa
Date: Fri Jun  4 09:49:30 2010
New Revision: 951346

URL: http://svn.apache.org/viewvc?rev=951346&view=rev
Log:
DERBY-2532: Client does not return SQLException on XAConnection.getXAResource() on a closed
connection, Embedded does 
Made ClientXAConnection.getXAResources throw an exception if the underlying
connection has been closed.

Patch contributed by Sabari S Kumar (swordfish1987 at iwanttobeme dot in).

Patch file: derby-2532-1a-getxares_on_closed_conn.diff


Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/ClientXAConnection.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/ClientXAConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/ClientXAConnection.java?rev=951346&r1=951345&r2=951346&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/ClientXAConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/ClientXAConnection.java Fri Jun
 4 09:49:30 2010
@@ -25,10 +25,12 @@ import java.sql.SQLException;
 import javax.sql.XAConnection;
 import javax.transaction.xa.XAResource;
 
+import org.apache.derby.client.am.ClientMessageId;
 import org.apache.derby.client.am.SqlException;
 import org.apache.derby.client.net.NetLogWriter;
 import org.apache.derby.client.net.NetXAConnection;
 import org.apache.derby.jdbc.ClientXADataSource;
+import org.apache.derby.shared.common.reference.SQLState;
 
 public class ClientXAConnection extends ClientPooledConnection implements XAConnection {
     private static int rmIdSeed_ = 95688932; // semi-random starting value for rmId
@@ -85,7 +87,12 @@ public class ClientXAConnection extends 
         if (logWriter_ != null) {
             logWriter_.traceExit(this, "getXAResource", xares_);
         }
-
+        // DERBY-2532
+        if (super.physicalConnection_ == null) {
+            throw new SqlException(logWriter_,
+                    new ClientMessageId(SQLState.NO_CURRENT_CONNECTION)
+                ).getSQLException();
+        }
         return xares_;
     }
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java?rev=951346&r1=951345&r2=951346&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
Fri Jun  4 09:49:30 2010
@@ -1860,12 +1860,9 @@ public class J2EEDataSourceTest extends 
 
         // test methods against a closed XAConnection and its resource
         try {
+            // (DERBY-2532)
             xac2.getXAResource();
-            // DERBY-2532
-            // Network Server does not think this is worth an exception.
-            if (usingEmbedded())
-                fail("expected SQLException on " +
-                    "closed XAConnection.getXAResource");
+            fail("expected SQLException on closed XAConnection.getXAResource");
         } catch (SQLException sqle) {
             assertSQLState("08003", sqle);
         }



Mime
View raw message