NPE in implicitassertions.Runtime.isVoidMethod #398

leonard84 opened this Issue Aug 11, 2015 · 1 comment


None yet

2 participants


The method Runtime.isVoidMethod does not handle the case of target being null and fails with a NPE.

Since most of Geb's own methods return empty strings, empty lists, or empty Navigators this problem does not occur often.

If you take this page, the at check won't fail because helper does not contain "test" or is null. It will cause an NPE.

class PageWithNullInAtChecker extends Page {
    static at = { helper()?.contains("test") }

    String helper() {
        return null
    at geb.transform.implicitassertions.Runtime.isVoidMethod(
    at geb.PageWithNullInAtChecker._clinit__closure1(PageOrientedSpec.groovy:533)
    at geb.PageWithNullInAtChecker._clinit__closure1(PageOrientedSpec.groovy)
    at geb.Page.verifyThisPageAtOnly(Page.groovy:228)
    at geb.Page.verifyAt(Page.groovy:182)
    at geb.Browser.doAt(Browser.groovy:455)
    at geb.test.GebSpec.methodMissing(GebSpec.groovy:91)
    at geb.PageOrientedSpec.implicit assertions should handle null(PageOrientedSpec.groovy:401)
@erdi erdi added the Bug label Aug 13, 2015
@erdi erdi added this to the 0.12.2 milestone Aug 13, 2015
@erdi erdi self-assigned this Aug 13, 2015
@erdi erdi added a commit to geb/geb that closed this issue Aug 13, 2015
@erdi erdi Fix NPE on implicitly asserted statements that contain a safely navig…
…ated method call on null target.

Closes geb/issues#398.
erdi commented Aug 13, 2015

Thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment