Skip to content

Conversation

SentryMan
Copy link
Collaborator

No description provided.

@SentryMan SentryMan merged commit ecdcd14 into avaje:master Jan 9, 2025
4 checks passed
@SentryMan SentryMan deleted the flush branch January 9, 2025 20:54
@rob-bygrave
Copy link
Contributor

Huh? Why? This seems incorrect?

BTW: Why are you merging stuff without a review?

try (var os = exchange.getResponseBody()) {
exchange.sendResponseHeaders(statusCode(), bytes.length == 0 ? -1 : bytes.length);
os.write(bytes);
os.flush();
Copy link
Contributor

@rob-bygrave rob-bygrave Jan 9, 2025

Choose a reason for hiding this comment

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

Why remove this one? Did you hit an issue with this or are you just seeing it as unnecessary?

Copy link
Collaborator Author

@SentryMan SentryMan Jan 9, 2025

Choose a reason for hiding this comment

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

Cause of this: robaho/httpserver#13 (comment)

also the tests passed so I honestly don't know why I added it in the first place

Copy link
Contributor

Choose a reason for hiding this comment

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

flush() should only be used when you have a long lived push type/events endpoint - otherwise is breaks pipelining optimizations. Although the current impl doesn’t use it, a close without flush can also make http2 hafar more efficient especially for short responses as the headers, data frame and end stream could be sent in a single tcp packet.

Ah, interesting - cool.

why I added it in the first place

You might not have written it. Some of this code has come from V2 Jex and some of that was a translation from Javalin ... and Javalin might have had those flush() calls there. So the thought I have is, did Javalin need to have those flush() calls / where they there for a reason [given that they are dealing with Jetty's OutputStream and we are dealing with the JDK Http Servers OutputStream only for this case].

@SentryMan
Copy link
Collaborator Author

SentryMan commented Jan 9, 2025

BTW: Why are you merging stuff without a review?

Right now I've been playing a little fast and loose since we've not yet deployed 3.0 (a total rewrite), shall I cease?

@rob-bygrave
Copy link
Contributor

little fast and loose ...

Maybe I'm old and crusty but "speed" imo really comes from moving forward with very few mistakes. That is, what is "Really Slow" is merging in changes where we don't detect as an issue/mistake ... and then only later on [potentially much later on] understanding the consequences - the "Oh Shit" moment.

In that sense 2 sets of eyes is always better that 1 because it increases the chance of detecting the "unforeseen side effect" of a given change.

In this case, we have subtly changed the semantics of write(byte[] bytes) ... we are pondering the consequences of that [e.g. for the error case, we try to see the normal response but determine we need to send the error response instead. For Helidon there are those cases where we need to use the isSent() check etc].

@SentryMan SentryMan added this to the 3.0 milestone Feb 3, 2025
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.

2 participants