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

Jetty-12 MetaData cleanup needed #7608

Closed
gregw opened this issue Feb 17, 2022 · 3 comments · Fixed by #9618
Closed

Jetty-12 MetaData cleanup needed #7608

gregw opened this issue Feb 17, 2022 · 3 comments · Fixed by #9618
Assignees

Comments

@gregw
Copy link
Contributor

gregw commented Feb 17, 2022

Target Jetty version(s)
Jetty-12

Enhancement Description

The MetaData class is badly in need of a clean up:

  • Too many constructors, with multiple paths through to super constructor.
  • The content-length handling is done poorly. It was meant to be an optimization to avoid HttpFields lookups when the content length is already known, but it now is more likely to cause a HttpFields lookup in every construction.
  • The content-length is sometimes set to -1 and sometimes set tio Integer.MIN_VALUE. I think the later is probably meant to indicate that a HttpFields lookup should be done. Eitherway, this needs to be clarified and perhaps some named constants used to communicate the intent.
  • Consideration could be given to using java-17 records
@gregw
Copy link
Contributor Author

gregw commented Feb 17, 2022

@lorban you want to tackle this, as you've already started. @sbordet anything to add?

@gregw gregw changed the title Jetty-12 META-DATA cleanup needed Jetty-12 MetaData cleanup needed Feb 17, 2022
@sbordet
Copy link
Contributor

sbordet commented Feb 22, 2022

@gregw cannot be a record as they cannot be subclassed, while MetaData needs to be subclassed.

Other than that, I would like to get consistent naming, for example getFields() should be renamed to getHttpFields() or getHeaders() because then we have the concept of trailer(s).

  • getFields() -> getHeaders()
  • getTrailerSupplier() -> getTrailersSupplier() (plural)
  • getURI() -> getHttpURI()
  • getURIString() -> really necessary? How can the _uri be null?

@github-actions
Copy link

This issue has been automatically marked as stale because it has been a
full year without activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@github-actions github-actions bot added the Stale For auto-closed stale issues and pull requests label Feb 23, 2023
@sbordet sbordet removed the Stale For auto-closed stale issues and pull requests label Feb 26, 2023
@joakime joakime self-assigned this Mar 29, 2023
@sbordet sbordet assigned sbordet and unassigned joakime and lorban Apr 3, 2023
sbordet added a commit that referenced this issue Apr 3, 2023
* Removed unnecessary constructors from MetaData, MetaData.Request and MetaData.Response.
* Removed MetaData.Request.getURIString() (available as getHttpURI().toString()).
* Renamed MetaData.getFields() -> getHttpFields(), as they can be headers or trailers.
* Renamed MetaData.Request.getURI() -> getHttpURI().
* Normalized handling of contentLength, now always -1 (rather than Long.MIN_VALUE) if unknown.
* Permutated MetaData.Response constructor parameters to be consistent with MetaData.Request.
* MetaData.Request's method and httpURI must be non-null.

Signed-off-by: Simone Bordet <[email protected]>
@sbordet sbordet linked a pull request Apr 3, 2023 that will close this issue
sbordet added a commit that referenced this issue Apr 7, 2023
* Removed unnecessary constructors from MetaData, MetaData.Request and MetaData.Response.
* Removed MetaData.Request.getURIString() (available as getHttpURI().toString()).
* Renamed MetaData.getFields() -> getHttpFields(), as they can be headers or trailers.
* Renamed MetaData.Request.getURI() -> getHttpURI().
* Normalized handling of contentLength, now always -1 (rather than Long.MIN_VALUE) if unknown.
* Permutated MetaData.Response constructor parameters to be consistent with MetaData.Request.
* MetaData.Request's method and httpURI must be non-null.

Signed-off-by: Simone Bordet <[email protected]>
@sbordet sbordet closed this as completed Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants