Skip to content

Commit d1ad887

Browse files
committed
Stick to Java enum conventions
1 parent 7620e51 commit d1ad887

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

client/src/main/java/org/asynchttpclient/netty/request/body/BodyChunkedInput.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ public ByteBuf readChunk(ChannelHandlerContext ctx) throws Exception {
5656
ByteBuffer buffer = ByteBuffer.allocate(chunkSize);
5757
Body.BodyState state = body.read(buffer);
5858
switch (state) {
59-
case Stop:
59+
case STOP:
6060
endOfInput = true;
6161
buffer.flip();
6262
return Unpooled.wrappedBuffer(buffer);
63-
case Suspend:
63+
case SUSPEND:
6464
//this will suspend the stream in ChunkedWriteHandler
6565
return null;
66-
case Continue:
66+
case CONTINUE:
6767
buffer.flip();
6868
return Unpooled.wrappedBuffer(buffer);
6969
default:

client/src/main/java/org/asynchttpclient/request/body/Body.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ enum BodyState {
2727
/**
2828
* There's something to read
2929
*/
30-
Continue,
30+
CONTINUE,
3131

3232
/**
3333
* There's nothing to read and input has to suspend
3434
*/
35-
Suspend,
35+
SUSPEND,
3636

3737
/**
3838
* There's nothing to read and input has to stop
3939
*/
40-
Stop;
40+
STOP;
4141
}
4242

4343
/**

client/src/main/java/org/asynchttpclient/request/body/generator/ByteArrayBodyGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public long getContentLength() {
3939
public BodyState read(ByteBuffer byteBuffer) throws IOException {
4040

4141
if (eof) {
42-
return BodyState.Stop;
42+
return BodyState.STOP;
4343
}
4444

4545
final int remaining = bytes.length - lastPosition;
@@ -50,7 +50,7 @@ public BodyState read(ByteBuffer byteBuffer) throws IOException {
5050
byteBuffer.put(bytes, lastPosition, byteBuffer.capacity());
5151
lastPosition = lastPosition + byteBuffer.capacity();
5252
}
53-
return BodyState.Continue;
53+
return BodyState.CONTINUE;
5454
}
5555

5656
public void close() throws IOException {

client/src/main/java/org/asynchttpclient/request/body/generator/InputStreamBodyGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public BodyState read(ByteBuffer buffer) throws IOException {
7878
buffer.put(chunk, 0, read);
7979
write = true;
8080
}
81-
return write ? BodyState.Continue : BodyState.Stop;
81+
return write ? BodyState.CONTINUE : BodyState.STOP;
8282
}
8383

8484
public void close() throws IOException {

client/src/main/java/org/asynchttpclient/request/body/generator/SimpleFeedableBodyGenerator.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void writeChunkBoundaries() {
5757

5858
public final class PushBody implements Body {
5959

60-
private BodyState state = BodyState.Continue;
60+
private BodyState state = BodyState.CONTINUE;
6161

6262
@Override
6363
public long getContentLength() {
@@ -67,18 +67,18 @@ public long getContentLength() {
6767
@Override
6868
public BodyState read(final ByteBuffer buffer) throws IOException {
6969
switch (state) {
70-
case Continue:
70+
case CONTINUE:
7171
return readNextPart(buffer);
72-
case Stop:
73-
return BodyState.Stop;
72+
case STOP:
73+
return BodyState.STOP;
7474
default:
7575
throw new IllegalStateException("Illegal process state.");
7676
}
7777
}
7878

7979
private BodyState readNextPart(ByteBuffer buffer) throws IOException {
80-
BodyState res = BodyState.Suspend;
81-
while (buffer.hasRemaining() && state != BodyState.Stop) {
80+
BodyState res = BodyState.SUSPEND;
81+
while (buffer.hasRemaining() && state != BodyState.STOP) {
8282
BodyPart nextPart = queue.peek();
8383
if (nextPart == null) {
8484
// Nothing in the queue. suspend stream if nothing was read. (reads == 0)
@@ -87,7 +87,7 @@ private BodyState readNextPart(ByteBuffer buffer) throws IOException {
8787
// skip empty buffers
8888
queue.remove();
8989
} else {
90-
res = BodyState.Continue;
90+
res = BodyState.CONTINUE;
9191
readBodyPart(buffer, nextPart);
9292
}
9393
}
@@ -102,7 +102,7 @@ private void readBodyPart(ByteBuffer buffer, BodyPart part) {
102102

103103
if (!part.buffer.hasRemaining() && !part.endPadding.hasRemaining()) {
104104
if (part.isLast) {
105-
state = BodyState.Stop;
105+
state = BodyState.STOP;
106106
}
107107
queue.remove();
108108
}

client/src/main/java/org/asynchttpclient/request/body/multipart/MultipartBody.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public BodyState read(ByteBuffer buffer) throws IOException {
100100
int maxLength = buffer.remaining();
101101

102102
if (currentPart == parts.size() && transfertDone) {
103-
return BodyState.Stop;
103+
return BodyState.STOP;
104104
}
105105

106106
boolean full = false;
@@ -173,11 +173,11 @@ public BodyState read(ByteBuffer buffer) throws IOException {
173173
}
174174
}
175175
}
176-
return transfertDone ? BodyState.Stop : BodyState.Continue;
176+
return transfertDone ? BodyState.STOP : BodyState.CONTINUE;
177177

178178
} catch (Exception e) {
179179
LOGGER.error("Read exception", e);
180-
return BodyState.Stop;
180+
return BodyState.STOP;
181181
}
182182
}
183183

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void readingBytesReturnsFedContentWithEmptyLastBufferWhenChunkBoundariesE
5252
assertEquals(readFromBody(body), "7\r\nTest123\r\n".getBytes(StandardCharsets.US_ASCII));
5353
feedableBodyGenerator.feed(ByteBuffer.allocate(0), true);
5454
assertEquals(readFromBody(body), "0\r\n\r\n".getBytes(StandardCharsets.US_ASCII));
55-
assertEquals(body.read(ByteBuffer.allocate(1)), BodyState.Stop);
55+
assertEquals(body.read(ByteBuffer.allocate(1)), BodyState.STOP);
5656
}
5757

5858
@Test(groups = "standalone")
@@ -63,7 +63,7 @@ public void readingBytesReturnsFedContentWithEmptyLastBufferWhenChunkBoundariesE
6363
feedableBodyGenerator.feed(ByteBuffer.allocate(0), true);
6464
Body body = feedableBodyGenerator.createBody();
6565
assertEquals(readFromBody(body), "7\r\nTest123\r\n0\r\n\r\n".getBytes(StandardCharsets.US_ASCII));
66-
assertEquals(body.read(ByteBuffer.allocate(1)), BodyState.Stop);
66+
assertEquals(body.read(ByteBuffer.allocate(1)), BodyState.STOP);
6767
}
6868

6969
@Test(groups = "standalone")
@@ -73,7 +73,7 @@ public void readingBytesReturnsFedContentWithFilledLastBufferWhenChunkBoundaries
7373
feedableBodyGenerator.feed(ByteBuffer.wrap(content), true);
7474
Body body = feedableBodyGenerator.createBody();
7575
assertEquals(readFromBody(body), "7\r\nTest123\r\n0\r\n\r\n".getBytes(StandardCharsets.US_ASCII));
76-
assertEquals(body.read(ByteBuffer.allocate(1)), BodyState.Stop);
76+
assertEquals(body.read(ByteBuffer.allocate(1)), BodyState.STOP);
7777

7878
}
7979

@@ -83,7 +83,7 @@ public void readingBytesReturnsFedContentWithoutChunkBoundariesWhenNotEnabled()
8383
feedableBodyGenerator.feed(ByteBuffer.wrap(content), true);
8484
Body body = feedableBodyGenerator.createBody();
8585
assertEquals(readFromBody(body), "Test123".getBytes(StandardCharsets.US_ASCII));
86-
assertEquals(body.read(ByteBuffer.allocate(1)), BodyState.Stop);
86+
assertEquals(body.read(ByteBuffer.allocate(1)), BodyState.STOP);
8787
}
8888

8989

@@ -95,7 +95,7 @@ public void returnZeroToSuspendStreamWhenNothingIsInQueue() throws Exception {
9595

9696
Body body = feedableBodyGenerator.createBody();
9797
assertEquals(readFromBody(body), "7\r\nTest123\r\n".getBytes(StandardCharsets.US_ASCII));
98-
assertEquals(body.read(ByteBuffer.allocate(1)), BodyState.Suspend);
98+
assertEquals(body.read(ByteBuffer.allocate(1)), BodyState.SUSPEND);
9999
}
100100

101101
private byte[] readFromBody(Body body) throws IOException {

client/src/test/java/org/asynchttpclient/request/body/generators/ByteArrayBodyGeneratorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void testSingleRead() throws IOException {
4949
assertEquals(chunkBuffer.position(), srcArraySize, "bytes read");
5050
chunkBuffer.clear();
5151

52-
assertEquals(body.read(chunkBuffer), BodyState.Stop, "body at EOF");
52+
assertEquals(body.read(chunkBuffer), BodyState.STOP, "body at EOF");
5353
}
5454

5555
@Test(groups = "standalone")
@@ -66,7 +66,7 @@ public void testMultipleReads() throws IOException {
6666

6767
int reads = 0;
6868
int bytesRead = 0;
69-
while (body.read(chunkBuffer) != BodyState.Stop) {
69+
while (body.read(chunkBuffer) != BodyState.STOP) {
7070
reads += 1;
7171
bytesRead += chunkBuffer.position();
7272
chunkBuffer.clear();

client/src/test/java/org/asynchttpclient/request/body/multipart/MultipartBodyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private static void compareContentLength(final List<Part> parts) throws IOExcept
6969
final ByteBuffer buffer = ByteBuffer.allocate(8192);
7070
boolean last = false;
7171
while (!last) {
72-
if (multipartBody.read(buffer) == BodyState.Stop) {
72+
if (multipartBody.read(buffer) == BodyState.STOP) {
7373
last = true;
7474
}
7575
}

0 commit comments

Comments
 (0)