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

TracingInterceptor throws NullPointerException if arguments contains a null argument

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.5, 3.0.6
    • 4.0.0-alpha-3, 3.0.9
    • groovy-jdk
    • None
    • Windows 10 Pro

    Description

      If a method is called with an argument having null value, beforeInvoke throws a NullPointerException.  Here is an example:

      class Foo {
         String say(String s)

      Unknown macro: {      return s    }

      }

      Foo foo = new Foo()

      def tracer = new TracingInterceptor()
      def proxyMetaClass = ProxyMetaClass.getInstance(Foo.class)
      proxyMetaClass.interceptor = tracer
      foo.metaClass = proxyMetaClass

      def s
      foo.say(s)

      This will cause a crash because s is null.  I believe inside writeInfo() method of TracingInterceptor, it has something like argument.getClass(). 

      In the example above, if we change foo.say(s) to foo.say(s as String) it would pass the beforeInvoke but still fails afterward.  If we actual set s to a non-null value, e.g.

      def s = 'Hello'

      the trace would work.

      Attachments

        Activity

          People

            emilles Eric Milles
            bocamel John Yin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h