Torque
  1. Torque
  2. TORQUE-111

Thrown RuntimeExceptions cause database connections to remain open

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 3.2, 3.3
    • Fix Version/s: 4.0-beta1
    • Component/s: Runtime
    • Labels:
      None

      Description

      In the doSelect(), doDelete(), doInsert(), and doUpdate() methods in BasePeer a database connection is obtained, some work performed, and then, if successful, the work is committed and the database connection is closed. If a TorqueException is thrown while performing the work, the work is rolled back and the database connection is closed. If a RuntimeException is thrown while performing the work, the work is not rolled back and the database connection remains open.

      The fix is simple: catch Exception (or Throwable) instead of TorqueException. This will ensure that, no matter what the problem is, Torque ensures the database connection is closed.

        Activity

        Hide
        Neil Weber added a comment -

        Added solution.

        Show
        Neil Weber added a comment - Added solution.
        Hide
        Thomas Fox added a comment -

        Caching Exceptions is not pretty because the exception should be rethrown and the mewthod should still only throw a TorqueException. Using a try..finally block is more elegant.

        Show
        Thomas Fox added a comment - Caching Exceptions is not pretty because the exception should be rethrown and the mewthod should still only throw a TorqueException. Using a try..finally block is more elegant.

          People

          • Assignee:
            Thomas Fox
            Reporter:
            Neil Weber
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 0.25h
              0.25h
              Remaining:
              Remaining Estimate - 0.25h
              0.25h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development