1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.buffer;
17
18 import java.nio.ByteOrder;
19
20
21
22
23
24 final class UnreleasableByteBuf extends WrappedByteBuf {
25
26 private SwappedByteBuf swappedBuf;
27
28 UnreleasableByteBuf(ByteBuf buf) {
29 super(buf);
30 }
31
32 @Override
33 public ByteBuf order(ByteOrder endianness) {
34 if (endianness == null) {
35 throw new NullPointerException("endianness");
36 }
37 if (endianness == order()) {
38 return this;
39 }
40
41 SwappedByteBuf swappedBuf = this.swappedBuf;
42 if (swappedBuf == null) {
43 this.swappedBuf = swappedBuf = new SwappedByteBuf(this);
44 }
45 return swappedBuf;
46 }
47
48 @Override
49 public ByteBuf readSlice(int length) {
50 return new UnreleasableByteBuf(buf.readSlice(length));
51 }
52
53 @Override
54 public ByteBuf slice() {
55 return new UnreleasableByteBuf(buf.slice());
56 }
57
58 @Override
59 public ByteBuf slice(int index, int length) {
60 return new UnreleasableByteBuf(buf.slice(index, length));
61 }
62
63 @Override
64 public ByteBuf duplicate() {
65 return new UnreleasableByteBuf(buf.duplicate());
66 }
67
68 @Override
69 public ByteBuf retain(int increment) {
70 return this;
71 }
72
73 @Override
74 public ByteBuf retain() {
75 return this;
76 }
77
78 @Override
79 public boolean release() {
80 return false;
81 }
82
83 @Override
84 public boolean release(int decrement) {
85 return false;
86 }
87 }