[
https://issues.apache.org/jira/browse/GROOVY-11858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18058716#comment-18058716
]
Eric Milles commented on GROOVY-11858:
--------------------------------------
The runtime is matching your {{split()}} call to the extension method
{{split(Object self, Closure closure)}}. "self" is the enclosing closure, not
the string delegate. And "closure" is null because the runtime allows
"foo.bar()" to be tried as "foo.bar(null)".
> Splitting string inside tap closure throws NullPointerException
> ---------------------------------------------------------------
>
> Key: GROOVY-11858
> URL: https://issues.apache.org/jira/browse/GROOVY-11858
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 5.0.4
> Reporter: Evan Shaw
> Priority: Major
>
> This code throws an exception:
> {code:groovy}
> 'a b c'.tap { println(split()) }
> {code}
> The exception message:
> {code}
> NullPointerException: Cannot invoke
> "groovy.lang.Closure.getMaximumNumberOfParameters()" because "wrapped" is null
> {code}
> If I pass an argument to split, it works as expected:
> {code:groovy}
> 'a b c'.tap { println(split(' ')) }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)