镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

java.lang.IllegalArgumentException: Bad position on Android 4.x #405

Description

@dmitrychistyakov

simple packString causes exception on Android 4.x, Android 5.x and later works fine (MsgPack 0.8.11)

String sampleText = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
            Map<String, String> sampleMap =  new HashMap<>();
            for(int i=0; i<100; i++) {
                sampleMap.put(String.valueOf(i), sampleText);
            }
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            MessagePacker packer = MessagePack.newDefaultPacker(out);
            packer.packMapHeader(sampleMap.size());
            for (Map.Entry<String, String> entry : sampleMap.entrySet()) {
                packer.packString(entry.getKey());
                packer.packString(entry.getValue());
            }

Exception stackTrace:

java.lang.IllegalArgumentException: Bad position (limit 7621): -568
	at java.nio.Buffer.positionImpl(Buffer.java:364)
	at java.nio.Buffer.position(Buffer.java:358)
	at java.nio.charset.CharsetEncoderICU.setPosition(CharsetEncoderICU.java:249)
	at java.nio.charset.CharsetEncoderICU.implFlush(CharsetEncoderICU.java:159)
	at java.nio.charset.CharsetEncoder.flush(CharsetEncoder.java:526)
	at org.msgpack.core.MessagePacker.encodeStringToBufferAt(MessagePacker.java:490)
	at org.msgpack.core.MessagePacker.packString(MessagePacker.java:549)
	...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions