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 Bug
    • Status: Closed Closed
    • Priority: Critical Critical
    • Resolution: Incomplete
    • Affects Version/s: 1.7.10
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      JDK 1.6
    • Testcase included:
      yes
    • Number of attachments :
      0

      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
      

        Activity

        No work has yet been logged on this issue.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: