File tree Expand file tree Collapse file tree 1 file changed +5
-13
lines changed
msgpack-core/src/main/java/org/msgpack/core/buffer Expand file tree Collapse file tree 1 file changed +5
-13
lines changed Original file line number Diff line number Diff line change 99public class ArrayBufferInput implements MessageBufferInput {
1010
1111 private MessageBuffer buffer ;
12- private int cursor ;
12+ private boolean isRead = false ;
1313 private final int length ;
1414
1515 public ArrayBufferInput (byte [] arr ) {
1616 this (arr , 0 , arr .length );
1717 }
1818
1919 public ArrayBufferInput (byte [] arr , int offset , int length ) {
20- this .buffer = MessageBuffer .wrap (checkNotNull (arr , "input array is null" ));
21- this .cursor = offset ;
20+ this .buffer = MessageBuffer .wrap (checkNotNull (arr , "input array is null" )).slice (offset , length );
2221 checkArgument (length <= arr .length );
2322 this .length = length ;
2423 }
2524
2625
2726 @ Override
2827 public MessageBuffer next () throws IOException {
29- if (cursor < length ) {
30- int c = cursor ;
31- cursor = length ;
32- if (c == 0 && length == buffer .size )
33- return buffer ;
34- else
35- return buffer .slice (c , length );
36- }
37- else {
28+ if (isRead )
3829 return null ;
39- }
30+ isRead = true ;
31+ return buffer ;
4032 }
4133
4234 @ Override
You can’t perform that action at this time.
0 commit comments