-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
Fixes #11363 by ensuring that read never throws, but instead returns an Error chunk.
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpChannelState.java
Show resolved
Hide resolved
} | ||
chunk = stream.read(); | ||
} | ||
catch (Throwable t) |
There was a problem hiding this comment.
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.
@@ -867,31 +867,38 @@ public long getLength() | |||
@Override | |||
public Content.Chunk read() | |||
{ | |||
HttpStream stream; | |||
try (AutoLock ignored = _lock.lock()) | |||
Content.Chunk chunk; |
There was a problem hiding this comment.
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.
Fixes #11363 by ensuring that read never throws, but instead returns an Error chunk.