1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.channel;
17
18
19
20
21
22 public class FixedRecvByteBufAllocator extends DefaultMaxMessagesRecvByteBufAllocator {
23
24 private final int bufferSize;
25
26 private final class HandleImpl extends MaxMessageHandle {
27 private final int bufferSize;
28
29 public HandleImpl(int bufferSize) {
30 this.bufferSize = bufferSize;
31 }
32
33 @Override
34 public int guess() {
35 return bufferSize;
36 }
37 }
38
39
40
41
42
43 public FixedRecvByteBufAllocator(int bufferSize) {
44 if (bufferSize <= 0) {
45 throw new IllegalArgumentException(
46 "bufferSize must greater than 0: " + bufferSize);
47 }
48 this.bufferSize = bufferSize;
49 }
50
51 @SuppressWarnings("deprecation")
52 @Override
53 public Handle newHandle() {
54 return new HandleImpl(bufferSize);
55 }
56
57 @Override
58 public FixedRecvByteBufAllocator respectMaybeMoreData(boolean respectMaybeMoreData) {
59 super.respectMaybeMoreData(respectMaybeMoreData);
60 return this;
61 }
62 }