Skip to content

Commit 77bbdfd

Browse files
committed
format
1 parent 2ec4e83 commit 77bbdfd

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

api/src/main/java/org/asynchttpclient/request/body/generator/FeedableBodyGenerator.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,23 @@ public long read(final ByteBuffer buffer) throws IOException {
9393
// skip empty buffers
9494
// if we return 0 here it would suspend the stream - we don't want that
9595
queue.remove();
96-
if(nextPart.isLast) {
97-
state = writeChunkBoundaries ? PushBodyState.CLOSING : PushBodyState.FINISHED;
96+
if (nextPart.isLast) {
97+
state = writeChunkBoundaries ? PushBodyState.CLOSING : PushBodyState.FINISHED;
9898
}
9999
return read(buffer);
100100
}
101101
int capacity = buffer.remaining() - 10; // be safe (we'll have to add size, ending, etc.)
102102
int size = Math.min(nextPart.buffer.remaining(), capacity);
103103
if (size != 0) {
104-
if(writeChunkBoundaries) {
104+
if (writeChunkBoundaries) {
105105
buffer.put(Integer.toHexString(size).getBytes(US_ASCII));
106106
buffer.put(END_PADDING);
107107
}
108108
for (int i = 0; i < size; i++) {
109109
buffer.put(nextPart.buffer.get());
110110
}
111-
if(writeChunkBoundaries) buffer.put(END_PADDING);
111+
if (writeChunkBoundaries)
112+
buffer.put(END_PADDING);
112113
}
113114
if (!nextPart.buffer.hasRemaining()) {
114115
if (nextPart.isLast) {

api/src/test/java/org/asynchttpclient/request/body/ChunkingTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ public void doTestWithFeedableBodyGenerator(InputStream is) throws Throwable {
100100
}
101101

102102
private void feed(FeedableBodyGenerator feedableBodyGenerator, InputStream is) throws IOException {
103-
try(InputStream inputStream = is) {
103+
try (InputStream inputStream = is) {
104104
byte[] buffer = new byte[512];
105-
for(int i =0; (i = inputStream.read(buffer)) > -1;) {
105+
for (int i = 0; (i = inputStream.read(buffer)) > -1;) {
106106
byte[] chunk = new byte[i];
107107
System.arraycopy(buffer, 0, chunk, 0, i);
108108
feedableBodyGenerator.feed(ByteBuffer.wrap(chunk), false);
@@ -114,12 +114,11 @@ private void feed(FeedableBodyGenerator feedableBodyGenerator, InputStream is) t
114114

115115
private AsyncHttpClientConfig.Builder httpClientBuilder() {
116116
return new AsyncHttpClientConfig.Builder()//
117-
.setAllowPoolingConnections(true)//
118-
.setMaxConnectionsPerHost(1)//
119-
.setMaxConnections(1)//
120-
.setConnectTimeout(1000)//
121-
.setRequestTimeout(1000)
122-
.setFollowRedirect(true);
117+
.setAllowPoolingConnections(true)//
118+
.setMaxConnectionsPerHost(1)//
119+
.setMaxConnections(1)//
120+
.setConnectTimeout(1000)//
121+
.setRequestTimeout(1000).setFollowRedirect(true);
123122
}
124123

125124
private void waitForAndAssertResponse(ListenableFuture<Response> responseFuture) throws InterruptedException, java.util.concurrent.ExecutionException, IOException {

api/src/test/java/org/asynchttpclient/request/body/generator/FeedableBodyGeneratorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void readingBytesReturnsFedContentWithoutChunkBoundariesWhenDisabled() th
6565

6666
private byte[] readFromBody(Body body) throws IOException {
6767
ByteBuffer byteBuffer = ByteBuffer.allocate(512);
68-
long read = body.read(byteBuffer);
68+
body.read(byteBuffer);
6969
byteBuffer.flip();
7070
byte[] readBytes = new byte[byteBuffer.remaining()];
7171
byteBuffer.get(readBytes);
@@ -84,4 +84,4 @@ public int getCalls() {
8484
return calls;
8585
}
8686
}
87-
}
87+
}

providers/netty3/src/main/java/org/asynchttpclient/netty/request/body/BodyChunkedInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public Object nextChunk() throws Exception {
5858
if (r < 0L) {
5959
endOfInput = true;
6060
return null;
61-
} else if(r == 0 && body instanceof FeedableBodyGenerator.PushBody) {
61+
} else if (r == 0 && body instanceof FeedableBodyGenerator.PushBody) {
6262
//this will suspend the stream in ChunkedWriteHandler
6363
return null;
6464
} else {

providers/netty4/src/main/java/org/asynchttpclient/netty/request/body/BodyChunkedInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public ByteBuf readChunk(ChannelHandlerContext ctx) throws Exception {
5858
if (r < 0L) {
5959
endOfInput = true;
6060
return null;
61-
} else if(r == 0 && body instanceof FeedableBodyGenerator.PushBody) {
61+
} else if (r == 0 && body instanceof FeedableBodyGenerator.PushBody) {
6262
//this will suspend the stream in ChunkedWriteHandler
6363
return null;
6464
} else {

providers/netty4/src/main/java/org/asynchttpclient/netty/request/body/NettyBodyBody.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void write(final Channel channel, NettyResponseFuture<?> future) throws I
6868

6969
BodyGenerator bg = future.getRequest().getBodyGenerator();
7070
if (bg instanceof FeedableBodyGenerator) {
71-
final FeedableBodyGenerator feedableBodyGenerator = FeedableBodyGenerator.class.cast(bg);
71+
final FeedableBodyGenerator feedableBodyGenerator = (FeedableBodyGenerator) bg;
7272
feedableBodyGenerator.setWriteChunkBoundaries(false);
7373
feedableBodyGenerator.setListener(new FeedListener() {
7474
@Override

0 commit comments

Comments
 (0)