Skip to content

NPE in implicitassertions.Runtime.isVoidMethod #398

@leonard84

Description

@leonard84

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
    }
}
java.lang.NullPointerException
    at geb.transform.implicitassertions.Runtime.isVoidMethod(Runtime.java:18)
    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.Browser.at(Browser.groovy:354)
    at geb.Browser.to(Browser.groovy:566)
    at geb.Browser.to(Browser.groovy:553)
    at geb.Browser.to(Browser.groovy:520)
    at geb.test.GebSpec.methodMissing(GebSpec.groovy:91)
    at geb.PageOrientedSpec.implicit assertions should handle null(PageOrientedSpec.groovy:401)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions