Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SnowYong opened this issue Mar 18, 2025 · 0 comments

Comments

@SnowYong
Copy link

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. ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant