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

Do not throw from HttpChannelState.read() method #11369

Merged
merged 3 commits into from
Feb 19, 2024

Conversation

gregw
Copy link
Contributor

@gregw gregw commented Feb 2, 2024

Fixes #11363 by ensuring that read never throws, but instead returns an Error chunk.

Fixes #11363 by ensuring that read never throws, but instead returns an Error chunk.
@joakime joakime changed the title No throw from read Do not throw from HttpChannelState.read() method Feb 2, 2024
@gregw gregw requested a review from sbordet February 5, 2024 03:31
}
chunk = stream.read();
}
catch (Throwable t)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would extend the try to the whole method.
The lines below should not throw, but neither the above should have, so I'd extend the scope of the try to the whole method to state the intention that the whole method must not throw, not only certain parts of the method.

@gregw gregw requested review from sbordet and joakime February 5, 2024 19:09
@@ -867,31 +867,38 @@ public long getLength()
@Override
public Content.Chunk read()
{
HttpStream stream;
try (AutoLock ignored = _lock.lock())
Content.Chunk chunk;
Copy link
Contributor

Choose a reason for hiding this comment

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

This line can be moved down now, as it is only used inside the try.

@gregw gregw requested a review from sbordet February 5, 2024 19:14
@gregw gregw merged commit b89c7eb into jetty-12.0.x Feb 19, 2024
8 checks passed
@gregw gregw deleted the fix/jetty-12/11363/nothrowFromRead branch February 19, 2024 08:28
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.

ContentSourcePublisher throws from request
3 participants