Skip to content

Generated marshaller break latin1 strings #602

@sf-db

Description

@sf-db

When POJOs with String fields containing unicode chars are put into the cache using generated marshaller - the encoding breaks, loosing unicode chars.

It seem to be related to optimization in createLambdaHelper.

package org.infinispan.protostream.impl;

import java.nio.charset.StandardCharsets;

public class TestProtostream {

    public static void main(String[] args) {
        String test = "Hélló, Prótóstréám!";

        // org.infinispan.protostream.impl.StringUtil.createLambdaHelper behaviour
        // Hélló, Prótóstréám! -> H�ll�, Pr�t�str��m!
        {
            StringUtil.Utf8Helper utf8Helper = StringUtil.UTF8_HELPER;

            byte[] encoded = utf8Helper.getBytes(test);
            String decoded = new String(encoded, StandardCharsets.UTF_8);

            System.out.println(test + " -> " + decoded);
        }

        // expected behaviour
        // Hélló, Prótóstréám! -> Hélló, Prótóstréám!
        {
            byte[] encoded = test.getBytes(StandardCharsets.UTF_8);
            String decoded = new String(encoded, StandardCharsets.UTF_8);

            System.out.println(test + " -> " + decoded);
        }
    }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions