Skip to content

[java] when deserializing string from cpp, it happens "java.lang.IllegalArgumentException: Invalid UTF-8" #8558

@SnowYong

Description

@SnowYong

Hi, good to see u.

I met one problem when deserializeing string from cpp to java.
Errors like below :

No pending exception expected: java.lang.IllegalArgumentException: Invalid UTF-8
at java.lang.String com.google.flatbuffers.Utf8Safe.decodeUtf8Array(byte[], int, int) (Utf8Safe.java:153)
at java.lang.String com.google.flatbuffers.Utf8Safe.decodeUtf8(java.nio.ByteBuffer, int, int) (Utf8Safe.java:260)
at java.lang.String com.google.flatbuffers.Table.__string(int, java.nio.ByteBuffer, com.google.flatbuffers.Utf8) (Table.java:113)
at java.lang.String com.google.flatbuffers.Table.__string(int) (Table.java:94)

it seems code located here -- Utf8Safe.jave

if (offset >= limit - 2) {
    throw new IllegalArgumentException("Invalid UTF-8");
}

I want to know which kind of String may cause this problem since i couldn't get the issue string from cpp as now.
if string contains '\r\n' or '\n', would it cause this kind of problem ??

Appreciate for ur response.
Have a good day. ^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions