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

MissingMethodException in Builder is misleading

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.6-beta-1
    • 2.4.6
    • groovy-jdk

    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

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

              Dates

                Created:
                Updated:
                Resolved: