File tree Expand file tree Collapse file tree 1 file changed +6
-17
lines changed
msgpack-core/src/main/java/org/msgpack/core/buffer Expand file tree Collapse file tree 1 file changed +6
-17
lines changed Original file line number Diff line number Diff line change @@ -54,24 +54,13 @@ public MessageBuffer next() throws IOException {
5454 if (reachedEOF )
5555 return null ;
5656
57- byte [] buffer = null ;
58- int cursor = 0 ;
59- while (!reachedEOF && cursor < bufferSize ) {
60- if (buffer == null ) {
61- buffer = new byte [bufferSize ];
62- }
63-
64- int readLen = -1 ;
65- // available() == 0 means, it reached the end of the stream
66- if (in .available () == 0 ||
67- (readLen = in .read (buffer , cursor , bufferSize - cursor )) == -1 ) {
68- reachedEOF = true ;
69- break ;
70- }
71- cursor += readLen ;
57+ byte [] buffer = new byte [bufferSize ];
58+ int readLen = in .read (buffer );
59+ if (readLen == -1 ) {
60+ reachedEOF = true ;
61+ return null ;
7262 }
73-
74- return buffer == null ? null : MessageBuffer .wrap (buffer ).slice (0 , cursor );
63+ return MessageBuffer .wrap (buffer ).slice (0 , readLen );
7564 }
7665
7766 @ Override
You can’t perform that action at this time.
0 commit comments