Navigation Menu

Skip to content
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

ByteArray deserialization is broken #7223

Closed
ondrej-hrstka opened this issue Apr 15, 2022 · 1 comment · Fixed by #7236
Closed

ByteArray deserialization is broken #7223

ondrej-hrstka opened this issue Apr 15, 2022 · 1 comment · Fixed by #7236

Comments

@ondrej-hrstka
Copy link
Contributor

Expected Behavior

When having DTO with ByteArray property, it should be deserialized from Base64 string representation during HTTP call.

Actual Behaviour

The response from the http call is 400 with message "Failed to convert argument [testDto] for value [null] due to: Instantiation of [simple type, class com.example.TestDto] value failed for JSON property content due to missing (therefore NULL) value for creator parameter content which is a non-nullable type\n at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: com.example.TestDto[\"content\"])"

DTO example:

data class TestDto(
    val content: ByteArray
)

HTTP call example:

curl -X POST --location "http://localhost:8080/deserialization" \
    -H "Content-Type: application/json" \
    -d "{
          \"content\": \"YWJj\"
        }"

Steps To Reproduce

Just run ./gradlew test in the example application.

Environment Information

  • Mac OS X 12.3.1
  • Java 17 Temurin, Kotlin 1.6.10

Example Application

https://github.com/ondrej-hrstka/bytearray-deserialization-issue

Version

3.4.2

@ondrej-hrstka
Copy link
Contributor Author

OK,

so I've debuged this deeper, and the problem is that the JsonNodeTraversingParser#getBinaryValue returns always null. Source code is here:

public byte[] getBinaryValue(Base64Variant b64variant) throws IOException {
return null;
}

I can try prepare the fix PR, but I will get to it on Wednesday soonest. I've also added more specific test.

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