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

MOP: Exceptions thrown by setters of closure delegate objects are ignored; values end up in the binding

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Incomplete
    • Affects Version/s: 1.7.10
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      JDK 1.6

      Description

      // Java delegate class
      public class TheDelegate {
             public void setDelegatesPropertyThrowsException(Object value)
                     throws javax.mail.internet.AddressException
             {
                     throw new AddressException("Just an example.");
             }
      }
      
      
      // the closure call (Java)
      public void methodThatTakesAClosure(Closure cl) {
             final TheDelegate delegate = new TheDelegate();
      
             // ...
      
             closure = (Closure)cl.clone();
             closure.setResolveStrategy(Closure.DELEGATE_FIRST);
             closure.setDelegate(delegate);
             closure.call(delegate); // no exception is seen here
      
             // ...
      }
      

      The following script does not get the exception thrown by setDelegatesPropertyThrowsException.

      // Groovy script
      thing.methodThatTakesAClosure {
             delegatesPropertyThrowsException = "tryThis"
      }
      
      assert delegatesPropertyThrowsException == "tryThis" // this was the MOP's second try
      

        Attachments

          Activity

            People

            • Assignee:
              blackdrag Jochen Theodorou
              Reporter:
              veita Alexander Veit
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: