-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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][Java]: Newly created instances of RemoteWebElement throw NPE on hashCode invocation #12442
Comments
@mykola-mokhnach, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
@mykola-mokhnach But why should anyone create I would suggest making default |
My case is a fairly complicated one. I was working on page-object-related stuff and it was necessary to keep objects in a hash map before they get initialized (since lazy initialization strategy is applied there). This is impossible though as both Set and HashMap keys call |
@mykola-mokhnach But what should I guess you should rather wrap |
I assume it should just call the original Object's hashCode method, so, this code holds
Unfortunately I did not find a good way to solve that yet because, like I said, the stuff is pretty complicated (part of page object implementation lies in selenium and the other part in the appium's java client). I would be happy to accept any better solution if anyone could propose one. Eventually, it does not seem right anyway an object would ever throw an exception on hashCode invocation. |
I would call the original hashCode method if |
yes, totally |
Pushed the change. I am trying to get 4.12 ready, but you can try this tomorrow with the Nightly https://www.selenium.dev/downloads/#nightly |
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. |
What happened?
After running the below code snippet a NPE is thrown.
This happens because the id property of the instance is unset (e.g. null) initially unless setId is called and hashCode is overridden as
This also means that newly created instances of RemoteWebElement cannot be compared or put into a map.
Expected result:
The hashCode implementation must never throw an exception.
How can we reproduce the issue?
Relevant log output
The text was updated successfully, but these errors were encountered: