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 in GuiceFactory masks root cause #2716

Closed
chriseldredge opened this issue Mar 28, 2023 · 1 comment
Closed

NullPointerException in GuiceFactory masks root cause #2716

chriseldredge opened this issue Mar 28, 2023 · 1 comment
Labels
🐛 bug Defect / Bug 🙏 help wanted Help wanted - not prioritized by core team

Comments

@chriseldredge
Copy link

👓 What did you see?

Using Cucumber JVM with my own implementation of InjectorSource, if my Guice modules are misconfigured and the injector fails to initialize, a runtime exception is thrown with root cause details (e.g. missing binding for a required interface).

However, when this happens, GuiceFactory.stop() gets invoked by Runner.disposeBackendWorlds() which is in turn invoked in a finally block in Runner.runPickle().

GuiceFactory.stop needs a null check to avoid NullPointerException, but the cleanup code in Runner should ideally also suppress exceptions and add them to the root cause exception (using Throwable.addSuppressed).

✅ What did you expect to see?

The root cause exception

📦 Which tool/library version are you using?

testImplementation("io.cucumber:cucumber-guice:7.11.2")
testImplementation("io.cucumber:cucumber-java:7.11.2")
testImplementation("io.cucumber:cucumber-testng:7.11.2")

🔬 How could we reproduce it?

Steps to reproduce the behavior:

  1. git clone https://github.com/chriseldredge/cucumber-guice-startup-exception-masked.git
  2. cd cucumber-guice-startup-exception-masked
  3. ./gradlew build
  4. View failure error in ./lib/build/reports/tests/test/index.html
@mpkorstanje
Copy link
Contributor

GuiceFactory.stop needs a null check to avoid NullPointerException

Agreed. Would you like to send a pull request for this?

the cleanup code in Runner should ideally also suppress exceptions and add them to the root cause exception (using Throwable.addSuppressed).

That's a bit trickier. I'll have to look for a good solution.

@mpkorstanje mpkorstanje added 🙏 help wanted Help wanted - not prioritized by core team 🐛 bug Defect / Bug labels Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Defect / Bug 🙏 help wanted Help wanted - not prioritized by core team
Projects
None yet
Development

No branches or pull requests

2 participants