You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2019/07/13 17:08:00 UTC

[jira] [Work logged] (CODEC-259) Broken java.nio.ByteBuffer support in org.apache.commons.codec.binary.Hex

     [ https://issues.apache.org/jira/browse/CODEC-259?focusedWorklogId=276317&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-276317 ]

ASF GitHub Bot logged work on CODEC-259:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 13/Jul/19 17:07
            Start Date: 13/Jul/19 17:07
    Worklog Time Spent: 10m 
      Work Description: Megaprog commented on pull request #23: CODEC-259: fixed ByteBuffer issues and updated tests
URL: https://github.com/apache/commons-codec/pull/23
 
 
   #CODEC-259
 
----------------------------------------------------------------
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:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 276317)
            Time Spent: 10m
    Remaining Estimate: 0h

> Broken java.nio.ByteBuffer support in org.apache.commons.codec.binary.Hex
> -------------------------------------------------------------------------
>
>                 Key: CODEC-259
>                 URL: https://issues.apache.org/jira/browse/CODEC-259
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.11, 1.12
>            Reporter: Tomas Shestakov
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> java.nio.ByteBuffer support in org.apache.commons.codec.binary.Hex does not work properly for direct ByteBuffer created by ByteBuffer.allocateDirect method and for heap ByteBuffers which arrayOffset() or byteBuffer.position() greater than zero:
> This test will produce java.lang.UnsupportedOperationException
> {code:java}
> @Test
> public void testEncodeHexByteBufferEmpty() {
>     assertTrue(Arrays.equals(new char[0], Hex.encodeHex(ByteBuffer.allocateDirect(0))));
> }
> {code}
> This one will fail
> {code:java}
> @Test
> public void testEncodeHexByteBufferHelloWorldLowerCaseHex() {
>     final ByteBuffer b = ByteBuffer.wrap(StringUtils.getBytesUtf8("[Hello World]"), 1, 11);
>     final String expected = "48656c6c6f20576f726c64";
>     char[] actual;
>     actual = Hex.encodeHex(b);
>     assertEquals(expected, new String(actual));
>     actual = Hex.encodeHex(b, true);
>     assertEquals(expected, new String(actual));
>     actual = Hex.encodeHex(b, false);
>     assertFalse(expected.equals(new String(actual)));
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)