[
https://issues.apache.org/jira/browse/DIRMINA-946?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13687790#comment-13687790
]
Emmanuel Lecharny commented on DIRMINA-946:
-------------------------------------------
The pb is that the ByteBuffer you are trying to dump is a DirectBuffer. If so,
the array() method won't work, because the byte[] is not visible in this case.
Morever, the array() method is not guaranteed to work.
I would suggest a slight modification in the patch : you can check if the BB
array() method is implemented with a hasArray() call. Always do that, just in
case. If the array() method is not supported, I suggest to copy the bytes into
a byte[], to spare the calls to slice.get(), and to avoid a code duplication at
the end of the method, when the dump is done as ascii.
Note that the current patch is buggy on line 91 : doing a buffer.get( bytes )
whithout flipping the buffer will change the buffer's position, thus impacting
the caller.
> ByteBufferDumper fails to dump ByteBuffers that are not backed by an array or
> that are readonly
> -----------------------------------------------------------------------------------------------
>
> Key: DIRMINA-946
> URL: https://issues.apache.org/jira/browse/DIRMINA-946
> Project: MINA
> Issue Type: Bug
> Components: Core
> Affects Versions: 3.0.0-trunk
> Reporter: Raphaƫl P. Barazzutti
> Assignee: Julien Vermillard
>
> ByteBufferDumper does a call to array() of the ByteBuffer, it throws an
> exception if that last one isn't read/write and backed by an array.
> fix available here:
> https://github.com/rbarazzutti/mina/tree/bufferdumper-fix
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira