Skip to content

Commit d29e110

Browse files
committed
ArrayBufferInput(MessageBuffer) accepts to null to make it empty
1 parent 2caf809 commit d29e110

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

msgpack-core/src/main/java/org/msgpack/core/buffer/ArrayBufferInput.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ public class ArrayBufferInput
2626
implements MessageBufferInput
2727
{
2828
private MessageBuffer buffer;
29-
private boolean isRead = false;
29+
private boolean isEmpty;
3030

3131
public ArrayBufferInput(MessageBuffer buf)
3232
{
33-
this.buffer = checkNotNull(buf, "input buffer is null");
33+
this.buffer = buf;
34+
if (buf == null) {
35+
isEmpty = true;
36+
}
37+
else {
38+
isEmpty = false;
39+
}
3440
}
3541

3642
public ArrayBufferInput(byte[] arr)
@@ -54,10 +60,10 @@ public MessageBuffer reset(MessageBuffer buf)
5460
MessageBuffer old = this.buffer;
5561
this.buffer = buf;
5662
if (buf == null) {
57-
this.isRead = true;
63+
isEmpty = true;
5864
}
5965
else {
60-
this.isRead = false;
66+
isEmpty = false;
6167
}
6268
return old;
6369
}
@@ -76,10 +82,10 @@ public void reset(byte[] arr, int offset, int len)
7682
public MessageBuffer next()
7783
throws IOException
7884
{
79-
if (isRead) {
85+
if (isEmpty) {
8086
return null;
8187
}
82-
isRead = true;
88+
isEmpty = true;
8389
return buffer;
8490
}
8591

@@ -88,6 +94,6 @@ public void close()
8894
throws IOException
8995
{
9096
buffer = null;
91-
isRead = true;
97+
isEmpty = true;
9298
}
9399
}

0 commit comments

Comments
 (0)