Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1876

try-finally does not always executes the finally block when used in methods with return values

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.0, 1.1-beta-1
    • 1.1-beta-2
    • None
    • None
    • Ubuntu Linux 6.10, Java SE 6, Groovy 1.1 Beta 1

    Description

      When using a try-finally block in methods with return values then the finally block will not always be executed.
      Here's a script which demonstrates the problem:

      boolean foo () {
      try

      { println "try" // only when next line is removed then the finally-block will be executed if (0 == 1) return false return true }

      finally

      { println "finally" }

      }

      foo ()

      Output after starting: eddie@saringnb:~$ groovy test.groovy
      try

      Finally will only be executed when removing the line " if (0 == 1) return false".

      I've reported a similar problem for Groovy 1.0 (http://jira.codehaus.org/browse/GROOVY-1663), probably it was not solved completely.

      BTW: Is there a planning for a bugfix release (e.g. 1.0.1) without new features which just removes these critical bugs? Would be important for production usage.

      Thanks in advance,
      Stefan

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            blackdrag Jochen Theodorou
            jede Stefan Saring
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment