You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "John Yin (Jira)" <ji...@apache.org> on 2021/04/05 14:12:00 UTC

[jira] [Created] (GROOVY-10009) TracingInterceptor throws NullPointerException if arguments contains a null argument

John Yin created GROOVY-10009:
---------------------------------

             Summary: TracingInterceptor throws NullPointerException if arguments contains a null argument
                 Key: GROOVY-10009
                 URL: https://issues.apache.org/jira/browse/GROOVY-10009
             Project: Groovy
          Issue Type: Bug
          Components: groovy-jdk
    Affects Versions: 3.0.6, 3.0.5
         Environment: Windows 10 Pro
            Reporter: John Yin


If a method is called with an argument having null value, beforeInvoke throws a NullPointerException.  Here is an example:
{quote}class Foo {
   String say(String s) {
     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)
{quote}
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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)