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

NullPointerException at Java8StepDefinition.isDefinedAt #1217

Closed
mpkorstanje opened this issue Sep 6, 2017 · 4 comments · Fixed by #1222
Closed

NullPointerException at Java8StepDefinition.isDefinedAt #1217

mpkorstanje opened this issue Sep 6, 2017 · 4 comments · Fixed by #1222

Comments

@mpkorstanje
Copy link
Contributor

Summary

Test failure produces this stack trace. Not sure about the circumstances:

java.lang.NullPointerException
	at cucumber.runtime.java8.Java8StepDefinition.isDefinedAt(Java8StepDefinition.java:111)
	at cucumber.runtime.StepDefinitionMatch.removeFrameworkFramesAndAppendStepLocation(StepDefinitionMatch.java:153)
	at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:44)
	at cucumber.api.TestStep.executeStep(TestStep.java:78)
	at cucumber.api.TestStep.run(TestStep.java:61)
	at cucumber.api.TestCase.run(TestCase.java:28)
	at cucumber.runner.Runner.runPickle(Runner.java:80)
	at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:140)
	at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68)
	at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73)
	at cucumber.api.junit.Cucumber.runChild(Cucumber.java:99)
	at cucumber.api.junit.Cucumber.runChild(Cucumber.java:41)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:393)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

Your Environment

  • Version used: cucumber-jvm:2.0.0
  • Operating System and version: Unix
@mpkorstanje mpkorstanje added the Bug label Sep 6, 2017
@brasmusson
Copy link
Contributor

Well, technically StackTraceElement.getFileName() can return null. It looks like if new Exception().getStackTrace()[3] was to return a StackTraceElement without the file name information, this stack trace would appear. However, I have not been able to reproduce the problem.

@mpkorstanje
Copy link
Contributor Author

I'll look into reproducing this.

@mpkorstanje
Copy link
Contributor Author

mpkorstanje commented Sep 12, 2017

I'm stumped.

  1. I can reproduce this exception by running my existing test set on the build server but not my development machine.
  2. A scenario must fail to produce the error, but not every failure generates the error.
  3. Repeated failure of the same scenario has an apparently random chance to produce this error.
  4. Failing steps range in complexity from trivial to complex. They are all lambda step definitions but just about every variation is covered.

This all leads me to thinking that it might be specific jdk version of the buildserver that has an issue in combination with some jdk jit magic.

Despite being unable to properly diagnose this I think following the technical specification would the right solution so: return location.getFileName() != null && location.getFileName().equals(stackTraceElement.getFileName());

mpkorstanje added a commit that referenced this issue Sep 12, 2017
The api allows `StackTraceElement.getFileName()`[1] to return null. We
were not able to reproduce this problem reliably but it occurred in
production environments anyway.

Fixes #1217

References:
 1. docs.oracle.com/javase/7/docs/api/java/lang/StackTraceElement.html#getFileName()
mpkorstanje added a commit that referenced this issue Sep 13, 2017
The api allows `StackTraceElement.getFileName()`[1] to return null. We
were not able to reproduce this problem reliably but it occurred in
production environments anyway.

Fixes #1217

References:
 1. docs.oracle.com/javase/7/docs/api/java/lang/StackTraceElement.html#getFileName()
@lock
Copy link

lock bot commented Oct 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants