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

Groovy swallowing exceptions when MissingMethodException occurs with a closure that throws an exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Cannot Reproduce
    • 1.6.3
    • 1.6.4, 1.7-beta-1
    • None
    • None

    Description

      The following code when run in Groovy console produces no output whatsoever:

      interface Callback {
         def execute();
      }
      
      def test(Callback callable) {
           println "crap"
      }
      
      test({ throw new Exception("ugly")} as Callback, true)
      

      The reason is the logic that formulates the message for the MissingMethodException is invoking the passed closure resulting in the exception contained within the closure being thrown and the original root cause being swallowed.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            graemerocher Graeme Rocher
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: