Derby
  1. Derby
  2. DERBY-4732

Release system resources in CanonTestCase thoroughly

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 10.7.1.1
    • Component/s: Test
    • Labels:
      None

      Description

      Now, in the method of compareCanon(String canon) in CanonTestcase, two BufferedReaders----cannonReader and testOutput are closed in try catch block, however if some exception occurs above, the two BufferReaders won't be closed, and related system resources won't be released.

      Besides, a releative problem is about the ByteArrayOutputStream rawBytes in CanonTestcase, it's created in getOutputStream() and closed in compareCanon(String canon). It's pointed out by Knut in Derby-2708, ByteArrayOutputStream's javadoc says that closing it has no effect, so tearDown() method has been added to CanonTestCase and sets rawBytes to null. It certainly can work. However, is it also OK to null out rawBytes in compareCanon(String canon)? If so, it seems cleaner than to null it out in tearDown() method.

      1. derby-4732.stat
        0.1 kB
        Yun Lee
      2. derby-4732.patch
        2 kB
        Yun Lee

        Issue Links

          Activity

          Yun Lee created issue -
          Yun Lee made changes -
          Field Original Value New Value
          Assignee Yun Lee [ yunlee ]
          Yun Lee made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Hide
          Yun Lee added a comment -

          In Derby-4732.patch, cannonReader and testOutput are closed in finally block to make sure they can be closed. Besides, rawBytes is nulled out in compareCanon() method and tearDown() method is removed.

          Show
          Yun Lee added a comment - In Derby-4732.patch, cannonReader and testOutput are closed in finally block to make sure they can be closed. Besides, rawBytes is nulled out in compareCanon() method and tearDown() method is removed.
          Yun Lee made changes -
          Attachment derby-4732.stat [ 12448781 ]
          Attachment derby-4732.patch [ 12448782 ]
          Yun Lee made changes -
          Link This issue is related to DERBY-2708 [ DERBY-2708 ]
          Yun Lee made changes -
          Issue & fix info [Patch Available]
          Hide
          Kristian Waagan added a comment -

          Seems like an improvement.
          I committed the patch to trunk with revision 963716.

          Show
          Kristian Waagan added a comment - Seems like an improvement. I committed the patch to trunk with revision 963716.
          Kristian Waagan made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Issue & fix info [Patch Available]
          Fix Version/s 10.7.0.0 [ 12314971 ]
          Resolution Fixed [ 1 ]
          Yun Lee made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Myrna van Lunteren made changes -
          Link This issue is part of DERBY-4609 [ DERBY-4609 ]
          Rick Hillegas made changes -
          Fix Version/s 10.7.1.1 [ 12315564 ]
          Fix Version/s 10.7.1.0 [ 12314971 ]
          Gavin made changes -
          Workflow jira [ 12515037 ] Default workflow, editable Closed status [ 12799722 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open In Progress In Progress
          2m 20s 1 Yun Lee 06/Jul/10 14:32
          In Progress In Progress Resolved Resolved
          7d 30m 1 Kristian Waagan 13/Jul/10 15:03
          Resolved Resolved Closed Closed
          18d 22h 33m 1 Yun Lee 01/Aug/10 13:36

            People

            • Assignee:
              Yun Lee
              Reporter:
              Yun Lee
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development