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

NPE possibly related to PojoWrapper

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.1
    • 1.8.2, 1.9-beta-3, 1.7.11
    • None
    • None

    Description

      Widget.groovy
      class Widget {
      }
      
      testscript.groovy
      Widget.metaClass.invokeMethod = { String methodName, Object[] args ->
          
          args.each { a ->
              println a.class
          }
      }
      
      w = new Widget()
      
      w.doSometing([] as Object[])
      

      With Groovy 1.8.0:

      pojoproblem $ groovy -version
      Groovy Version: 1.8.0 JVM: 1.6.0_26
      pojoproblem $ groovy testscript.groovy 
      class [Ljava.lang.Object;
      

      With Groovy 1.8.1:

      pojoproblem $ groovy -version
      Groovy Version: 1.8.1 JVM: 1.6.0_26
      pojoproblem $ groovy testscript.groovy 
      Caught: java.lang.NullPointerException
      java.lang.NullPointerException
      	at testscript$_run_closure1_closure2.doCall(testscript.groovy:4)
      	at testscript$_run_closure1.doCall(testscript.groovy:3)
      	at testscript.run(testscript.groovy:10)
      

      I think (not 100% sure) the NPE is related to the delegate property in PojoWrapper being null. PojoWrapper.getProperty(String) is called, which looks like this:

          public Object getProperty(final String property) {
              return this.delegate.getProperty(this.wrapped, property);
          }
      

      Is the wrapper really supposed to be passed into the closure or is it supposed to be the unwrapped object?

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            brownj Jeff Brown
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: