db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel John Debrunner (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-2620) embedded throws SQLState 8003 (No current connection) on rs.next() on closed resultSet in test for DERBY-1025 in DataSourceTest
Date Tue, 08 May 2007 00:11:15 GMT

    [ https://issues.apache.org/jira/browse/DERBY-2620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12494164
] 

Daniel John Debrunner commented on DERBY-2620:
----------------------------------------------

I see the code above is from the DataSource test.
 Is there a reason for catching the exceptions (in the first block) and calling fail() in
the catch block? The test will fail if the exceptions are thrown without a catch block and
the junit runner will show a stack trace. With the fail it will not be clear which method
caused the problem, or where the exception was actually thrown from.

And in the second case, is it the next() or getInt() that is expected to fail? Putting two
method calls that can throw the same exception when expecting one of them to fail is  a way
of hiding errors and being confusing to the test reader. E.g. if the next() is meant to succeed
and the getInt() fail then the test would pass even if the next() throws an exception. If
the next() is meant to fail() then what's the purpose of  calling getInt()?

> embedded throws SQLState 8003 (No current connection) on rs.next() on closed resultSet
in test for DERBY-1025 in DataSourceTest
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-2620
>                 URL: https://issues.apache.org/jira/browse/DERBY-2620
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>            Reporter: Kathey Marsden
>         Assigned To: Kathey Marsden
>
> The following code checking that a CLOSE_CURSORS_AT_COMMIT ResultSet is closed by xa_start
 throws the wrong exception for embedded, indicating that there is no current connection instead
of the ResultSet  being closed.
>    Statement s4 = conn4.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
ResultSet.CLOSE_CURSORS_AT_COMMIT);
>         ResultSet rs4 = s4.executeQuery("select i from autocommitxastart");
>         rs4.next();
>         assertEquals(1, rs4.getInt(1));
>         rs4.next();
>         assertEquals(2, rs4.getInt(1));
>         // XAResource().start should commit the transaction
>         try {
>             xac4.getXAResource().start(xid4a, XAResource.TMNOFLAGS);
>             xac4.getXAResource().end(xid4a, XAResource.TMSUCCESS);
>         } catch (XAException xae) {
>             fail("unexpected XAException on xac4.getXAResource.start or end");
>         } catch (Exception e) {
>             fail("unexpected Exception on xac4.getXAResource.start or end");
>         }
>         
>         // DERBY-1025.
>         // With Embedded, this will give error: 08003 - No current connection
>         // But with NetworkServer / DerbyNetClient, the transaction does not
>         // appear to be closed, and we actually get a value.
>         try {
>             rs4.next();
>             rs4.getInt(1);            
>             fail ("expected an exception indicating resultset is closed.");
>         } catch (SQLException sqle) {
>             // Embedded gets 08003.
>         	if (usingDerbyNetClient())
>         		assertSQLState("XCL16",sqle);
>         }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message