@@ -68,7 +68,7 @@ public synchronized Iterable<ByteBuffer> split(ByteBuffer inputByteBuffer) {
68
68
69
69
// If current buffer is not empty, fill the buffer first.
70
70
if (currentBuffer .position () != 0 ) {
71
- fillBuffer (inputByteBuffer );
71
+ fillCurrentBuffer (inputByteBuffer );
72
72
73
73
if (isCurrentBufferFull ()) {
74
74
addCurrentBufferToIterable (byteBuffers , chunkSize );
@@ -77,7 +77,7 @@ public synchronized Iterable<ByteBuffer> split(ByteBuffer inputByteBuffer) {
77
77
78
78
// If the input buffer is not empty, split the input buffer
79
79
if (inputByteBuffer .hasRemaining ()) {
80
- splitInputBuffer (inputByteBuffer , byteBuffers );
80
+ splitRemainingInputByteBuffer (inputByteBuffer , byteBuffers );
81
81
}
82
82
83
83
// If this is the last chunk, add data buffered to the iterable
@@ -92,18 +92,18 @@ private boolean isCurrentBufferFull() {
92
92
return currentBuffer .position () == chunkSize ;
93
93
}
94
94
95
- private void splitInputBuffer (ByteBuffer buffer , List <ByteBuffer > byteBuffers ) {
96
- while (buffer .hasRemaining ()) {
97
- ByteBuffer chunkByteBuffer = buffer .asReadOnlyBuffer ();
98
- if (buffer .remaining () < chunkSize ) {
99
- currentBuffer .put (buffer );
95
+ private void splitRemainingInputByteBuffer (ByteBuffer inputByteBuffer , List <ByteBuffer > byteBuffers ) {
96
+ while (inputByteBuffer .hasRemaining ()) {
97
+ ByteBuffer inputByteBufferCopy = inputByteBuffer .asReadOnlyBuffer ();
98
+ if (inputByteBuffer .remaining () < chunkSize ) {
99
+ currentBuffer .put (inputByteBuffer );
100
100
break ;
101
101
}
102
102
103
- int newLimit = chunkByteBuffer .position () + chunkSize ;
104
- chunkByteBuffer .limit (newLimit );
105
- buffer .position (newLimit );
106
- byteBuffers .add (chunkByteBuffer );
103
+ int newLimit = inputByteBufferCopy .position () + chunkSize ;
104
+ inputByteBufferCopy .limit (newLimit );
105
+ inputByteBuffer .position (newLimit );
106
+ byteBuffers .add (inputByteBufferCopy );
107
107
transferredBytes .addAndGet (chunkSize );
108
108
}
109
109
}
@@ -123,7 +123,7 @@ private void addCurrentBufferToIterable(List<ByteBuffer> byteBuffers, int capaci
123
123
currentBuffer .clear ();
124
124
}
125
125
126
- private void fillBuffer (ByteBuffer inputByteBuffer ) {
126
+ private void fillCurrentBuffer (ByteBuffer inputByteBuffer ) {
127
127
while (currentBuffer .position () < chunkSize ) {
128
128
if (!inputByteBuffer .hasRemaining ()) {
129
129
break ;
0 commit comments