Skip to content

Commit a820714

Browse files
committed
remove dead code
1 parent 27f9112 commit a820714

File tree

2 files changed

+0
-65
lines changed

2 files changed

+0
-65
lines changed

client/src/main/java/org/asynchttpclient/util/ByteBufUtils.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@
2020
import java.nio.charset.Charset;
2121
import java.nio.charset.StandardCharsets;
2222
import java.util.Collections;
23-
import java.util.List;
2423

2524
public final class ByteBufUtils {
2625

27-
public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
28-
2926
private ByteBufUtils() {
3027
}
3128

@@ -61,29 +58,4 @@ public static byte[] byteBuf2Bytes(ByteBuf buf) {
6158
buf.getBytes(readerIndex, array);
6259
return array;
6360
}
64-
65-
public static byte[] byteBufs2Bytes(List<ByteBuf> bufs) {
66-
67-
if (bufs.isEmpty()) {
68-
return EMPTY_BYTE_ARRAY;
69-
70-
} else if (bufs.size() == 1) {
71-
return byteBuf2Bytes(bufs.get(0));
72-
73-
} else {
74-
int totalSize = 0;
75-
for (ByteBuf buf : bufs) {
76-
totalSize += buf.readableBytes();
77-
}
78-
79-
byte[] bytes = new byte[totalSize];
80-
int offset = 0;
81-
for (ByteBuf buf : bufs) {
82-
int readable = buf.readableBytes();
83-
buf.getBytes(buf.readerIndex(), bytes, offset, readable);
84-
offset += readable;
85-
}
86-
return bytes;
87-
}
88-
}
8961
}

client/src/test/java/org/asynchttpclient/netty/util/ByteBufUtilsTest.java

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
import io.netty.buffer.ByteBuf;
55
import io.netty.buffer.Unpooled;
66

7-
import java.util.Collections;
8-
import java.util.LinkedList;
9-
import java.util.List;
10-
117
import org.asynchttpclient.util.ByteBufUtils;
128
import org.testng.annotations.Test;
139

@@ -29,37 +25,4 @@ public void testByteBuf2BytesNoBackingArray() {
2925
byte[] output = ByteBufUtils.byteBuf2Bytes(inputBuf);
3026
assertEquals(output, inputBytes, "The bytes returned by byteBuf2Bytes do not match the bytes in the ByteBuf parameter");
3127
}
32-
33-
@Test
34-
public void testByteBufs2BytesEmptyList() {
35-
byte[] output = ByteBufUtils.byteBufs2Bytes(Collections.emptyList());
36-
assertEquals(output, ByteBufUtils.EMPTY_BYTE_ARRAY,
37-
"When an empty list is passed to byteBufs2Bytes, an empty byte array should be returned");
38-
}
39-
40-
@Test
41-
public void testByteBufs2BytesSize1List() {
42-
byte[] inputBytes = "testdata".getBytes();
43-
ByteBuf inputBuf = Unpooled.copiedBuffer(inputBytes);
44-
byte[] output = ByteBufUtils.byteBufs2Bytes(Collections.singletonList(inputBuf));
45-
assertEquals(output, inputBytes, "When a list of a single ByteBuf element is passed to byteBufs2Bytes,"
46-
+ " the returned byte array should contain the bytes in that ByteBUf");
47-
}
48-
49-
@Test
50-
public void testByteBufs2Bytes() {
51-
byte[] input1 = "testdata".getBytes();
52-
byte[] input2 = "testdata2".getBytes();
53-
byte[] input3 = "testdata3333".getBytes();
54-
55-
List<ByteBuf> byteBufList = new LinkedList<>();
56-
byteBufList.add(Unpooled.copiedBuffer(input1));
57-
byteBufList.add(Unpooled.copiedBuffer(input2));
58-
byteBufList.add(Unpooled.copiedBuffer(input3));
59-
60-
byte[] output = ByteBufUtils.byteBufs2Bytes(byteBufList);
61-
assertEquals(output.length, input1.length + input2.length + input3.length,
62-
"Returned bytes length should equal the sum of the parts");
63-
}
64-
6528
}

0 commit comments

Comments
 (0)