Skip to content

Commit

Permalink
invert order of parameters and make minChunSize final
Browse files Browse the repository at this point in the history
  • Loading branch information
franz1981 committed May 29, 2023
1 parent 7bf38a3 commit cecc9c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
*/
final class AppendBuffer {
private final ByteBufAllocator allocator;

private final int minChunkSize;
private final int capacity;
private ByteBuf buffer;
private ArrayDeque<ByteBuf> otherBuffers;
private int size;
private int minChunkSize;

private AppendBuffer(ByteBufAllocator allocator, int capacity, int minChunkSize) {
private AppendBuffer(ByteBufAllocator allocator, int minChunkSize, int capacity) {
this.allocator = allocator;
this.capacity = capacity;
this.minChunkSize = Math.min(minChunkSize, capacity);
this.capacity = capacity;
}

/**
Expand All @@ -37,16 +38,16 @@ public static AppendBuffer eager(ByteBufAllocator allocator, int capacity) {
* The data is consolidated in a single {@link CompositeByteBuf} on {@link #clear}.
*/
public static AppendBuffer exact(ByteBufAllocator allocator, int capacity) {
return new AppendBuffer(allocator, capacity, 0);
return new AppendBuffer(allocator, 0, capacity);
}

/**
* This buffer append data in multiples {@link ByteBuf}s which minimum capacity is {@code minChunkSize} or
* as each {@code len}, if greater than it.<br>
* The data is consolidated in a single {@link CompositeByteBuf} on {@link #clear}.
*/
public static AppendBuffer withMinChunks(ByteBufAllocator allocator, int capacity, int minChunkSize) {
return new AppendBuffer(allocator, capacity, minChunkSize);
public static AppendBuffer withMinChunks(ByteBufAllocator allocator, int minChunkSize, int capacity) {
return new AppendBuffer(allocator, minChunkSize, capacity);
}

private ByteBuf lastBuffer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public class ResteasyReactiveOutputStream extends OutputStream {
public ResteasyReactiveOutputStream(VertxResteasyReactiveRequestContext context) {
this.context = context;
this.request = context.getContext().request();
this.appendBuffer = AppendBuffer.withMinChunks(PooledByteBufAllocator.DEFAULT,
context.getDeployment().getResteasyReactiveConfig().getOutputBufferSize(), DEFAULT_MIN_CHUNK_SIZE);
this.appendBuffer = AppendBuffer.withMinChunks(PooledByteBufAllocator.DEFAULT, DEFAULT_MIN_CHUNK_SIZE,
context.getDeployment().getResteasyReactiveConfig().getOutputBufferSize());
request.response().exceptionHandler(new Handler<Throwable>() {
@Override
public void handle(Throwable event) {
Expand Down

0 comments on commit cecc9c4

Please sign in to comment.