code-ferry opened a new pull request #327:
URL: https://github.com/apache/commons-io/pull/327


   The currentBufferIndex means the index of the current buffer in the class 
AbstractByteArrayOutputStream. 
   when creating new buffer first time and the write size , currentBufferIndex 
should not change.
   
   Luckily, this mistable does not affect any public methods and the result. 
After my modification, all the unit tests also pass.
   
   ```
       @Test
       public void testCurrentBufferIndex() throws IOException, 
IllegalAccessException, InstantiationException, NoSuchFieldException {
           ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
           outputStream.write(new byte[]{0x31, 0x32});
   
           // Get Field currentBufferIndex
           Field field = 
ByteArrayOutputStream.class.getSuperclass().getDeclaredField("currentBufferIndex");
           field.setAccessible(true);
           int currentBufferIndex = (int) field.get(outputStream);
   
           // print 1. I think the right value is 0.
           //
           // Only 2 bytes are written, less than the default value 1024.
           // The size of array buffers is only 1, and currentBufferIndex 
should be 0.
           System.out.println(currentBufferIndex);
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to