[jbossts-issues] [JBoss JIRA] (JBTM-3262) improve string serialization

Jonathan Halliday (Jira) issues at jboss.org
Thu Mar 5 08:18:04 EST 2020


     [ https://issues.redhat.com/browse/JBTM-3262?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Halliday updated JBTM-3262:
------------------------------------
    Description: 
Core's handling of unicode string packing is, not to put too fine a point on it, wrong.

OutputBuffer's packString(String s) assumes the serialized form of a UTF-8 string has the same number of bytes as the String has code units, which is incorrect for any String containing multi-byte code units.

Since that needs fixing anyhow, the refactoring pulls out the byte[] packing to a separate function from the String encoding, additionally enabling a performance optimization:

Where a fixed String is packed frequently, the transformation to byte[] can be done once and cached, eliding memory allocation and processing on subsequent invocations. This is particularly useful for the StateManager marker, which is packed to buffers with great frequency.

  was:Core's handling of unicode string packing is, not to put too fine a point on it, wrong.



> improve string serialization
> ----------------------------
>
>                 Key: JBTM-3262
>                 URL: https://issues.redhat.com/browse/JBTM-3262
>             Project: JBoss Transaction Manager
>          Issue Type: Bug
>          Components: Transaction Core
>    Affects Versions: 5.10.3.Final
>            Reporter: Jonathan Halliday
>            Assignee: Jonathan Halliday
>            Priority: Minor
>
> Core's handling of unicode string packing is, not to put too fine a point on it, wrong.
> OutputBuffer's packString(String s) assumes the serialized form of a UTF-8 string has the same number of bytes as the String has code units, which is incorrect for any String containing multi-byte code units.
> Since that needs fixing anyhow, the refactoring pulls out the byte[] packing to a separate function from the String encoding, additionally enabling a performance optimization:
> Where a fixed String is packed frequently, the transformation to byte[] can be done once and cached, eliding memory allocation and processing on subsequent invocations. This is particularly useful for the StateManager marker, which is packed to buffers with great frequency.



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jbossts-issues mailing list