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
Draining bug fix #4750
Draining bug fix #4750
Conversation
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 won't die on the case class hill.
|
||
package org.http4s.ember.core | ||
|
||
private[ember] final case class EmptyStreamError() extends Exception("Cannot Parse Empty Stream") |
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.
Nit: I don't love exceptions being case classes. It implies equality where there is none. I see you're using it as an extractor, but I usually catch these by type.
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 is also not a hill I'll die on, but every other exception type defined in that package is also a case class, and most of them are not used in a match clause :) . If we want to go one way or the other, I'm all for for following well-defined guidelines
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.
Agree, I care about consistency more than which way we go. Let's merge, and we can revisit the case class bikeshed.
Fixes #4731. The issue here was that we would drain a socket's read buffer before the response was written to the socket. This can manifest in the aforementioned bug because the input stream will only be evaluated when we try to write. But if we drain the connection before we write, we'll end up closing because we see unread bytes.
So the fix is to drain after the response is written to the socket. I've also done some QoL to make things easier to read and follow. There might be some merge conflicts with #4735 which I can deal with
TODO: