3 Replies Latest reply on Sep 10, 2010 6:02 AM by Tim Fox

    Issues with determining String size for encoding

    Jeff Mesnil Master

      Yesterday, clebert and I fixed https://jira.jboss.org/browse/HORNETQ-503 but there is a more general problem with determining String size to encode it in the buffer.

      Everywhere we use BufferHelper.sizeOfNullableSimpleString(String) or BufferHelper.sizeOfSimpleString(String) to determine the encoded size of a String, we may have issue is the String is not encoded as a SimpleString.

      In ChannelBufferWrapper.writeStringInternal(String), the way the String is encoded depends on its size. It can be encoded as shorts, as a SimpleString or as a UTF-8 String. Only when the String is encoded as a SimpleString, the size determined by BufferHelper.sizeOfSimpleString(String) would be correct. In all other cases, the size is not correct and could result in data loss.

      To fix this we need to change the sizeOfXXXString() to return the correct size depending on the String length and not assume that every String will be encoded as a SimpleString.


      After a quick look, this affect only persistence of JMS resources in the journal.