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

[grid] & [java] jdk http client - avoid chunking without buffering to memory #11198

Merged
merged 1 commit into from
Oct 31, 2022

Conversation

joerg1985
Copy link
Member

Description

Some drivers do not implement transfer-encoding chunked e.g. Chrome
The jdk http client implementation did solve this by buffering the request body into a byte array.
The new implementation will only buffer into memory if the content-length is not know.

@pujagani I think this was the reason the BodyPublishers.ofInputStream did not work, while BodyPublishers.ofByteArray did work with Edge and Chrome drivers.

Motivation and Context

The implementation of ProtocolHandshake#createSession does use a FileBackedOutputStream to keep the memory
consumption low for big requests. The jdk http client did not handle this and did buffer the complete request to memory.
This change will help not to buffer the new session request.

When the jdk http client is used for the grid, the size of the payload is usually known.
This change will also help not to buffer these request while sending them to the driver.

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.

Reduce the memory consumption especially while creating a new session.
@codecov-commenter
Copy link

Codecov Report

Base: 52.67% // Head: 52.67% // No change to project coverage 👍

Coverage data is based on head (be7fc17) compared to base (f569d7f).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #11198   +/-   ##
=======================================
  Coverage   52.67%   52.67%           
=======================================
  Files          82       82           
  Lines        5542     5542           
  Branches      198      198           
=======================================
  Hits         2919     2919           
  Misses       2425     2425           
  Partials      198      198           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@pujagani pujagani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @joerg1985 for looking into this. It does solve the chunking problem seen earlier with InputStream. I ran multiple scenarios locally with the changes and confirmed the chunking problem is solved. I have also tested that changes in ProtocolHandshake do not effect either of the HTTP clients. Appreciate the efficient solution

@pujagani pujagani merged commit e0ade5c into SeleniumHQ:trunk Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants