Skip to content

[java] fix null request in case of chunked request #13113

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

Merged
merged 6 commits into from
Nov 14, 2023

Conversation

nikhlagrwl
Copy link
Contributor

@nikhlagrwl nikhlagrwl commented Nov 8, 2023

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Selenium throws a NullPointerException in case of chunked request. The request object is initialised after sending 100 response for chunked requests and hence for the last chunk of the request, the request object is null.

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@CLAassistant
Copy link

CLAassistant commented Nov 8, 2023

CLA assistant check
All committers have signed the CLA.

@titusfortner titusfortner added the C-java Java Bindings label Nov 8, 2023
@codecov-commenter
Copy link

codecov-commenter commented Nov 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b27523b) 57.52% compared to head (b9b67b9) 57.52%.
Report is 1 commits behind head on trunk.

❗ Current head b9b67b9 differs from pull request most recent head d26ff1d. Consider uploading reports for the commit d26ff1d to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #13113   +/-   ##
=======================================
  Coverage   57.52%   57.52%           
=======================================
  Files          86       86           
  Lines        5299     5299           
  Branches      221      221           
=======================================
  Hits         3048     3048           
  Misses       2030     2030           
  Partials      221      221           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joerg1985
Copy link
Member

@nikhlagrwl thanks for opening the PR, what client are you using to have chunked requests?
Some drivers do not support chunked requests, therefore you might run into simil ar issues with your client when directly connecting to a driver. So there might also be a client issue to fix, beside the server issue.

@nikhlagrwl
Copy link
Contributor Author

nikhlagrwl commented Nov 9, 2023

@nikhlagrwl thanks for opening the PR, what client are you using to have chunked requests? Some drivers do not support chunked requests, therefore you might run into simil ar issues with your client when directly connecting to a driver. So there might also be a client issue to fix, beside the server issue.

@joerg1985 I tried with a ruby client and even with curl command, it's failing on both the case.
Getting the below error on server in both the scenario
07:12:57.574 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception. java.lang.NullPointerException: Cannot invoke "org.openqa.selenium.remote.http.HttpRequest.setContent(java.util.function.Supplier)" because "this.request" is null

@joerg1985
Copy link
Member

@nikhlagrwl could you share the curl call?

@nikhlagrwl
Copy link
Contributor Author

@nikhlagrwl could you share the curl call?

echo '{"desiredCapabilities":{"browserName": "firefox"},"requiredCapabilities":{}}' | curl -N -X POST --connect-timeout 20 --data-binary @- -H "Transfer-Encoding: chunked" -H 'Content-Type: application/json; charset=utf-8' -H 'Expect: 100-continue' http://localhost:4444/wd/hub/session -vvv

@diemol
Copy link
Member

diemol commented Nov 10, 2023

@nikhlagrwl could you share the curl call?

echo '{"desiredCapabilities":{"browserName": "firefox"},"requiredCapabilities":{}}' | curl -N -X POST --connect-timeout 20 --data-binary @- -H "Transfer-Encoding: chunked" -H 'Content-Type: application/json; charset=utf-8' -H 'Expect: 100-continue' http://localhost:4444/wd/hub/session -vvv

Please note, that payload is not valid anymore as it is JWP, not W3C WebDriver.

@titusfortner
Copy link
Member

please run ./scripts/format.sh to fix the linting issues

@nikhlagrwl
Copy link
Contributor Author

@titusfortner Resolved linting issues

@titusfortner titusfortner merged commit 8cd85d5 into SeleniumHQ:trunk Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-java Java Bindings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants