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

[🐛 Bug]: NullPointerException while using DevTools instance with JDK 11 Http Client #12882

Closed
pujagani opened this issue Oct 6, 2023 · 2 comments · Fixed by #13165
Closed
Labels
C-devtools BiDi or Chrome DevTools related issues C-java I-defect

Comments

@pujagani
Copy link
Contributor

pujagani commented Oct 6, 2023

What happened?

Using JDK 11 Http Client prevents reusing of DevTools instance. Earlier, this was not a problem since Selenium used a single instance of AsyncHttpClient and it was only closed when the JVM shuts down. But with the JdkHttpClient, Selenium uses a new instance each time and closes it too.
Changes made as part of #11345, which assigns the client to null while closing causes an NPE when re-using DevTools instance. The changes were made to prevent memory leaks.

I am not sure about the right approach to address this. I will need to look into it further.

How can we reproduce the issue?

Run https://github.com/SeleniumHQ/selenium/blob/trunk/java/test/org/openqa/selenium/devtools/DevToolsReuseTest.java with JDK 11 Http Client

Relevant log output

Cannot invoke "java.net.http.HttpClient.newWebSocketBuilder()" because "this.client" is null
java.lang.NullPointerException: 
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient.openSocket(JdkHttpClient.java:168)
	at org.openqa.selenium.devtools.Connection.reopen(Connection.java:92)
	at org.openqa.selenium.devtools.DevTools.createSession(DevTools.java:129)
	at org.openqa.selenium.devtools.DevTools.createSession(DevTools.java:117)
	at org.openqa.selenium.devtools.DevToolsReuseTest.shouldBeAbleToCloseDevToolsAndCreateNewInstance(DevToolsReuseTest.java:41)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

Operating System

macOS Ventura

Selenium version

Java 4.13.0

What are the browser(s) and version(s) where you see this issue?

Chrome 117

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver Version: 117.0.5938.149

Are you using Selenium Grid?

No response

@pujagani pujagani added I-defect needs-triaging C-java C-devtools BiDi or Chrome DevTools related issues and removed needs-triaging labels Oct 6, 2023
@github-actions
Copy link

github-actions bot commented Oct 6, 2023

@pujagani, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

Copy link

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

@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-devtools BiDi or Chrome DevTools related issues C-java I-defect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant