Skip to content

Fixes #12916 - Bad example in JavaDoc of InputStreamResponseListener.#12927

Merged
sbordet merged 1 commit into
jetty-12.0.xfrom
fix/jetty-12.0.x/12916/inputstreamresponselistener-autocloseable
Mar 21, 2025
Merged

Fixes #12916 - Bad example in JavaDoc of InputStreamResponseListener.#12927
sbordet merged 1 commit into
jetty-12.0.xfrom
fix/jetty-12.0.x/12916/inputstreamresponselistener-autocloseable

Conversation

@sbordet

@sbordet sbordet commented Mar 20, 2025

Copy link
Copy Markdown
Contributor

Made InputStreamResponseListener implement AutoCloseable. Updated tests, javadocs and documentation.

Made InputStreamResponseListener implement AutoCloseable.
Updated tests, javadocs and documentation.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet moved this to 👀 In review in Jetty 12.0.19 - FROZEN Mar 20, 2025
@sbordet sbordet linked an issue Mar 20, 2025 that may be closed by this pull request
@sbordet sbordet requested a review from lorban March 20, 2025 16:00
@sbordet sbordet self-assigned this Mar 20, 2025
@sbordet sbordet merged commit c63239f into jetty-12.0.x Mar 21, 2025
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Jetty 12.0.19 - FROZEN Mar 21, 2025
@sbordet sbordet deleted the fix/jetty-12.0.x/12916/inputstreamresponselistener-autocloseable branch March 21, 2025 10:18
@Override
public void close() throws IOException
{
stream.updateAndGet(input -> input == null ? InputStream.nullInputStream() : input).close();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This doesn't really change anything if the stream was never created.

I expected this to release all chunks that have been received already, and probably abort an already demanded but not yet received chunk, or maybe the whole response (does that actually happen in Input.close?).

So when the InputStream hasn't been created yet, the behavior should be similar to getInputStream().close(). You could achieve this by changing this slightly to create a real Input instead of a nullInputStream, or you could try avoiding to create a stream and invoking the corresponding logic directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mperktold good catch!

@sbordet sbordet restored the fix/jetty-12.0.x/12916/inputstreamresponselistener-autocloseable branch March 21, 2025 10:53
@sbordet sbordet deleted the fix/jetty-12.0.x/12916/inputstreamresponselistener-autocloseable branch March 21, 2025 10:55
sbordet added a commit that referenced this pull request Mar 23, 2025
Fixed InputStreamResponseListener.close() to properly flip the `closed` field.
Made InputStreamResponseListener.close() and InputStreamResponseListener.Input.close() call the same code.
Fixed buffer leaking by releasing the network buffer upon connection close in HTTP and FCGI.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
sbordet added a commit that referenced this pull request Mar 23, 2025
Fixed InputStreamResponseListener.close() to properly flip the `closed` field.
Made InputStreamResponseListener.close() and InputStreamResponseListener.Input.close() call the same code.
Fixed buffer leaking by releasing the network buffer upon connection close in HTTP and FCGI.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet

sbordet commented Mar 23, 2025

Copy link
Copy Markdown
Contributor Author

See also #12931.

@sbordet

sbordet commented Mar 23, 2025

Copy link
Copy Markdown
Contributor Author

@mperktold can you please review #12931?

@mperktold

Copy link
Copy Markdown

@sbordet looks good now!

I see that you also improved releasing the buffers, that's great! 👍

sbordet added a commit that referenced this pull request Mar 25, 2025
* Fixed InputStreamResponseListener.close() to properly flip the `closed` field.
* Made InputStreamResponseListener.close() and InputStreamResponseListener.Input.close() call the same code.
* Fixed buffer leaking by releasing the network buffer upon connection close in HTTP and FCGI.
* Fixed race in HTTP2Stream.
  A DATA frame could have been enqueued even if the stream was reset or failed, and stay there without being released.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Bad example in JavaDoc of InputStreamResponseListener

3 participants