Serenity-core: StackTraceAnalyser class "getMethod" calls "callingClass.getSuperclass"(Line 36), and passes to extractMethod. But its not necessary that there be superclass(Inner nested single interface lambda implementation). Leads to Nullpointer

Created on 15 Sep 2020  路  7Comments  路  Source: serenity-bdd/serenity-core

StackTraceAnalyser class "getMethod" calls callingClass.getSuperclass, and passes it to extractMethod. But its not necessary that there be superclass. Leads to Nullpointer. Especially when the call is from Junit 5 execution engine I am getting Nullpointer for "ExecutableInvoker" class which has a inner interface single method implementation for "ReflectiveInterceptorCall" which does not have a super class. Leading to Nullpointer exception in "extractMethod" because callingClass is passed as null.

image
image
image
image
image
image
image
image
image

Most helpful comment

2295 was release with v2.3.9

All 7 comments

Can you propose a PR to fix?

@wakaleo Sure. Should i just handle the "null" returned in "callingClass.getSuperclass" or should i pass the ReflectiveInterceptorCall reference too to the extractMethod? I am not sure whether we need to dig in to these classes as these are core Junit5 classes and no logical need to in this usecase. However if there is some nested single method lambda interface defined in a class where a "screenshot" annotation is applied then we ideally should(I am not sure whether thats a valid use case)

I would just handle the null by ignoring it, as this code is to detect annotations in the test code itself, not in JUnit code.

Thanks @wakaleo . Will raise PR to handle this

Had the same issue: StackTraceAnalyser runs into a NullPointerException for stacktrace element org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) because org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall is a inner interface and does not have a superclass. (StackTraceAnalyser#36)

2295 was release with v2.3.9

This is working as expected now. Hence closing this issue. Thank you @fabianlinz and @wakaleo

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vaibhav2701 picture vaibhav2701  路  8Comments

knludi picture knludi  路  4Comments

dan0935 picture dan0935  路  5Comments

scormaq picture scormaq  路  3Comments

dineshbalajibingo picture dineshbalajibingo  路  5Comments