JDO
  1. JDO
  2. JDO-415

DataStoreConnection assumes datastore transactions are being used

    Details

      Description

      org.apache.jdo.tck.api.persistencemanager.DataStoreConnection assumes that the connection returned from getDataStoreConnection will be re-used once a JDO transaction is started, but that assertion is only valid when using datastore transactions, and the test case does not ensure that a datastore transaction is being used.

      The solution is to call "getPM().currentTransaction().setOptimistic(false);" just before "getPM().currentTransaction().begin();" in the testDataStoreConnection() test case.

      1. JDO-415.patch
        2 kB
        Craig L Russell

        Activity

        Hide
        Craig L Russell added a comment -

        Please review this patch.

        There are three problems with the original test case.

        1. As the bug noted, the DataStoreConnection is acquired outside a transaction, and there is no guarantee that the DataStoreConnection is even valid after beginning a transaction. So I changed the code to acquire the DataStoreConnection only after beginning a transaction.

        2. If the implementation supports Optimistic transactions, then the test should be repeated for both optimistic and datastore transactions.

        3. The transaction is never committed. This is fixed by putting the DataStoreConnection close and the transaction.commit into the finally block.

        Show
        Craig L Russell added a comment - Please review this patch. There are three problems with the original test case. 1. As the bug noted, the DataStoreConnection is acquired outside a transaction, and there is no guarantee that the DataStoreConnection is even valid after beginning a transaction. So I changed the code to acquire the DataStoreConnection only after beginning a transaction. 2. If the implementation supports Optimistic transactions, then the test should be repeated for both optimistic and datastore transactions. 3. The transaction is never committed. This is fixed by putting the DataStoreConnection close and the transaction.commit into the finally block.
        Hide
        Michael Bouschen added a comment -

        The patch looks good!

        Show
        Michael Bouschen added a comment - The patch looks good!
        Hide
        Craig L Russell added a comment -

        svn commit src/java/org/apache/jdo/tck/api/persistencemanager
        Sending src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java
        Transmitting file data .
        Committed revision 453089.

        Show
        Craig L Russell added a comment - svn commit src/java/org/apache/jdo/tck/api/persistencemanager Sending src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java Transmitting file data . Committed revision 453089.
        Hide
        Craig L Russell added a comment -

        Commit for the branch/2.0.1

        svn commit -m "JDO-415"
        Sending tck20/src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java
        Transmitting file data .
        Committed revision 453090.

        Show
        Craig L Russell added a comment - Commit for the branch/2.0.1 svn commit -m " JDO-415 " Sending tck20/src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java Transmitting file data . Committed revision 453090.

          People

          • Assignee:
            Craig L Russell
            Reporter:
            Marc Prud'hommeaux
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development