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

MissingMethodException in Builder is misleading

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6-beta-1
    • Fix Version/s: 2.4.6
    • Component/s: groovy-jdk
    • Labels:

      Description

      Test Case:

      class Foo extends BuilderSupport {
          public void setParent(Object parent, Object child){
              parent.setFoo(child)
          }
          public Object createNode(Object name){
              return createNode(name,(Object)null)
          }
          
          public Object createNode(Object name, Object value){
              return createNode(name,[:],value)
          }
          
          public Object createNode(Object name, Map attributes){
              return createNode(name,attributes,null)
          }
          
          public Object createNode(Object name, Map attributes, Object value){
            return "${name}"      
          }
      
      }
      
      try {
        def f = new Foo()
        f.foo {
          bar()
        }
      } catch(MissingMethodException e) {
        assert e.method == "setFoo",  "was ${e.method}"
      }
      

      It's actually the method setFoo that is missing, but it is reported as bar that is missing. Any MissingMethodException thrown while inside a Builder will be misreported in this way.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pascalschumacher Pascal Schumacher
                Reporter:
                iamnoah Noah Sloan
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: