ufolr opened a new pull request #195: Fix 
CharArrayBuffer.subSequence(beganIndex,endIndex) to return right result.
URL: https://github.com/apache/httpcomponents-core/pull/195
 
 
   **CharArrayBuffer** implemented the **CharSequence** interface, 
   and **CharSequence** define method `public CharSequence subSequence(final 
int beginIndex, final int endIndex)`
   Threre are two problem in original implementation of 
`CharArrayBuffer.subSequence`
   
   1. It call `CharBuffer.wrap(buffer.array, beginIndex, endIndex)` 
directly,but the 3rd parameter of the `CharBuffer.wrap` method is length, it 
means how many chars need to copy, not endIndex. It makes some problem such as 
pass CharArrayBuffer as a CharSequence in to Regex's matcher method like 
following:   
   ```CharArrayBuffer charSequence = new CharArrayBuffer(8);   
           charSequence.append("aabb123c");   
           Pattern p = Pattern.compile("\\D*(\\d+)\\D*");   
           Matcher m = p.matcher(charSequence);   
           Assert.assertEquals("123", m.find()?m.group(1):""); 
   ```
   
   2. **CharArrayBuffer's** sub-sequence should return the result as same class 
of **CharArrayBuffer**. But' the old implementation use `CharBuffer.wrap` to 
make a result which instance of **HeapCharBuffer**. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to