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 simplify Retainable.canRetain usage #9159

Merged
merged 1 commit into from
Jan 13, 2023

Conversation

gregw
Copy link
Contributor

@gregw gregw commented Jan 12, 2023

I believe that canRetain is no longer needed. The only place it is used for real logic is in AsyncContent, which can use it's own chunk class to pass on how to succeed the callback.

@gregw gregw requested review from sbordet and lorban January 12, 2023 03:47
@gregw gregw changed the title Fix/jetty 12 remove retainable.canRetain Jetty 12 remove Retainable.canRetain Jan 12, 2023
@gregw
Copy link
Contributor Author

gregw commented Jan 12, 2023

@sbordet @lorban the main change in this PR is in AsyncContent, everything else is just a mechanical removal of canRetain.

Copy link
Contributor

@lorban lorban left a comment

Choose a reason for hiding this comment

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

I've added a comment with a quick summary of our discussion around Content.asChunk and canRetain for future reference.

*/
static Chunk asChunk(ByteBuffer byteBuffer, boolean last, Retainable retainable)
{
if (!retainable.canRetain())
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the most important spot where canRetain is used. We must not allow linking the lifecycle of a Chunk that potentially contains a pooled buffer to the lifecycle of non-retaining retainables like EOF or EMPTY.

While this check is a nice to have extra safeguard and the current code would work without it, it was added because that error is way too easy to make and hard to track down.

@gregw gregw requested a review from lorban January 12, 2023 09:48
Copy link
Contributor

@lorban lorban left a comment

Choose a reason for hiding this comment

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

LGTM

Base automatically changed from fix/jetty-12-remove-chunk-isTerminal to jetty-12.0.x January 13, 2023 00:11
`Retainable`s that return false from `canRetain` now are noops if `retain` is called, which allows for a simpler calling convention.
AsyncContent has also been reworked to allocate less and be clearer in its use of `canRetain`.
@gregw gregw force-pushed the fix/jetty-12-remove-chunk-isTerminal-noRetain branch from 0b9f1b4 to 4655b61 Compare January 13, 2023 02:59
@gregw gregw changed the title Jetty 12 remove Retainable.canRetain Jetty 12 simplify Retainable.canRetain usage Jan 13, 2023
@gregw gregw requested a review from lorban January 13, 2023 03:00
@gregw
Copy link
Contributor Author

gregw commented Jan 13, 2023

@sbordet @lorban rebased against HEAD of jetty-12.0.x after merge of #9073

@sbordet sbordet merged commit 8b3bcc3 into jetty-12.0.x Jan 13, 2023
@sbordet sbordet deleted the fix/jetty-12-remove-chunk-isTerminal-noRetain branch January 13, 2023 09:37
gregpoulos pushed a commit to gregpoulos/jetty.project that referenced this pull request Jan 16, 2023
…x-document-modules

* upstream/jetty-12.0.x:
  Issue jetty#9167 - making assumption in flaky test
  jetty 12.0.x cleanup duplicate osgi pom metadata (jetty#9093)
  Jetty 12 - Add tests in util/resource for alternate FileSystem implementations (jetty#9149)
  Cleanup non-retainable `Retainable`s (jetty#9159)
  Fixes retainability of special Chunks (jetty#9073)
  TCK: Dispatch forward and includes attributes do not meet the spec (jetty#9074)
  re-enable h3 tests (jetty#8773)
  More fundamental test case
  Reorganization of jetty-client classes. (jetty#9127)
  Removing @disabled from SslUploadTest
  Removing @disabled from jetty-start
  jetty#9134 added test
  ee10: DefaultServlet: Replace checks for isStreaming() by !isWriting()
  jetty#9078 make HttpContent.getByteBuffer() implementations return new ByteBuffer instances and document that contract
  Fixes jetty#9141 - Thread-safe Content.Chunk#slice (jetty#9142)
  Remove `@Disabled` from `jetty-jmx` (jetty#9143)
  Bump maven.version from 3.8.6 to 3.8.7
  Bump maven.version from 3.8.6 to 3.8.7
gregpoulos pushed a commit to gregpoulos/jetty.project that referenced this pull request Jan 16, 2023
… into jetty-12.0.x-documentation-lowercase-jetty_home-attribute

* 'jetty-12.0.x' of https://github.com/eclipse/jetty.project:
  Issue jetty#9167 - making assumption in flaky test
  jetty 12.0.x cleanup duplicate osgi pom metadata (jetty#9093)
  Jetty 12 - Add tests in util/resource for alternate FileSystem implementations (jetty#9149)
  Cleanup non-retainable `Retainable`s (jetty#9159)
  Fixes retainability of special Chunks (jetty#9073)
  TCK: Dispatch forward and includes attributes do not meet the spec (jetty#9074)
  re-enable h3 tests (jetty#8773)
  More fundamental test case
  Reorganization of jetty-client classes. (jetty#9127)
  Removing @disabled from SslUploadTest
  Removing @disabled from jetty-start
  Bump maven.version from 3.8.6 to 3.8.7
  Bump maven.version from 3.8.6 to 3.8.7
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