Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #2229

Closed
naveenchandra91 opened this issue Sep 15, 2020 · 7 comments

Comments

@naveenchandra91
Copy link

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

@wakaleo
Copy link
Member

wakaleo commented Sep 15, 2020

Can you propose a PR to fix?

@naveenchandra91
Copy link
Author

@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)

@wakaleo
Copy link
Member

wakaleo commented Sep 17, 2020

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.

@naveenchandra91
Copy link
Author

Thanks @wakaleo . Will raise PR to handle this

fabianlinz added a commit to fabianlinz/serenity-core that referenced this issue Nov 12, 2020
… classes without a superclass (serenity-bdd#2229)

* no tests adjusted as I did not find tests for the different cases in StackTraceAnalyser
wakaleo pushed a commit that referenced this issue Nov 12, 2020
… classes without a superclass (#2229) (#2295)

* no tests adjusted as I did not find tests for the different cases in StackTraceAnalyser
@fabianlinz
Copy link
Contributor

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)

@fabianlinz
Copy link
Contributor

#2295 was release with v2.3.9

@naveenchandra91
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants