Skip to content

Commit

Permalink
No need to use response methods returning a Future, if not used (part…
Browse files Browse the repository at this point in the history
… II)
  • Loading branch information
franz1981 committed Nov 25, 2022
1 parent 5614878 commit 6adf11e
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MultivaluedMap;

import io.netty.buffer.Unpooled;
import org.jboss.logging.Logger;
import org.jboss.resteasy.reactive.server.core.LazyResponse;
import org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext;
Expand All @@ -24,6 +25,7 @@
public class ResteasyReactiveOutputStream extends OutputStream {

private static final Logger log = Logger.getLogger("org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveOutputStream");
private static final Buffer EMPTY_BUFFER = Buffer.buffer(Unpooled.EMPTY_BUFFER);
private final ResteasyReactiveRequestContext context;
protected final HttpServerRequest request;
private final int outputBufferSize;
Expand Down Expand Up @@ -80,7 +82,7 @@ Buffer createBuffer(ByteBuf data) {

public void write(ByteBuf data, boolean last) throws IOException {
if (last && data == null) {
request.response().end();
request.response().end(EMPTY_BUFFER, null);
return;
}
//do all this in the same lock
Expand All @@ -104,9 +106,9 @@ public void write(ByteBuf data, boolean last) throws IOException {
data.release();
} else {
if (last) {
request.response().end(createBuffer(data));
request.response().end(createBuffer(data), null);
} else {
request.response().write(createBuffer(data));
request.response().write(createBuffer(data), null);
}
}
} catch (Exception e) {
Expand Down Expand Up @@ -160,9 +162,9 @@ public void handle(Void event) {
if (overflow != null) {
if (overflow.size() > 0) {
if (closed) {
request.response().end(Buffer.buffer(overflow.toByteArray()));
request.response().end(Buffer.buffer(overflow.toByteArray()), null);
} else {
request.response().write(Buffer.buffer(overflow.toByteArray()));
request.response().write(Buffer.buffer(overflow.toByteArray()), null);
}
overflow.reset();
}
Expand Down

0 comments on commit 6adf11e

Please sign in to comment.