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

null value for DriverUrl annotation throws internal exception #410

Closed
cwensel opened this issue Sep 12, 2023 · 2 comments
Closed

null value for DriverUrl annotation throws internal exception #410

cwensel opened this issue Sep 12, 2023 · 2 comments

Comments

@cwensel
Copy link

cwensel commented Sep 12, 2023

Description of the problem:

if the value of the an annotated field is null, and exception is thrown.

	@DriverUrl()
	static String driverUrl = null;

This does not cause a failure in the test, but does emit a spooky stack trace

Possibly use Optional.ofNullable instead of Optional.of.

Our tests will use local browsers if the remote driver is not running, we do this by setting driverUrl to null.

2023-09-12 15:59:33 [main] WARN  i.g.b.seljup.AnnotationsReader.seekFieldAnnotatedWith(174) -- Exception seeking field in null annotated with interface io.github.bonigarcia.seljup.DriverUrl
java.lang.NullPointerException: null
	at java.base/java.util.Objects.requireNonNull(Objects.java:221)
	at java.base/java.util.Optional.<init>(Optional.java:107)
	at java.base/java.util.Optional.of(Optional.java:120)
	at io.github.bonigarcia.seljup.AnnotationsReader.getField(AnnotationsReader.java:193)
	at io.github.bonigarcia.seljup.AnnotationsReader.seekFieldAnnotatedWith(AnnotationsReader.java:163)
	at io.github.bonigarcia.seljup.AnnotationsReader.seekFieldAnnotatedWith(AnnotationsReader.java:145)
	at io.github.bonigarcia.seljup.AnnotationsReader.getUrl(AnnotationsReader.java:100)
	at io.github.bonigarcia.seljup.SeleniumJupiter.findUrl(SeleniumJupiter.java:276)
	at io.github.bonigarcia.seljup.SeleniumJupiter.resolveSeleniumWebDriver(SeleniumJupiter.java:188)
	at io.github.bonigarcia.seljup.SeleniumJupiter.resolveParameter(SeleniumJupiter.java:170)
	at io.github.bonigarcia.seljup.SeleniumJupiter$1$1.resolveParameter(SeleniumJupiter.java:604)
	at org.junit.jupiter.engine.execution.ParameterResolutionUtils.resolveParameter(ParameterResolutionUtils.java:136)
	at org.junit.jupiter.engine.execution.ParameterResolutionUtils.resolveParameters(ParameterResolutionUtils.java:103)
	at org.junit.jupiter.engine.execution.ParameterResolutionUtils.resolveParameters(ParameterResolutionUtils.java:64)
	at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:84)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:217)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:213)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:138)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at ```
@bonigarcia
Copy link
Owner

Thanks for reporting. I'll look into it as soon as I find some time.

@bonigarcia
Copy link
Owner

This should be fixed in Selenium-Jupiter 5.0.0, just released.

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

No branches or pull requests

2 participants