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

Unable to parse json bytes containing WrappedMessage #379

Open
ryanemerson opened this issue Dec 6, 2024 · 1 comment
Open

Unable to parse json bytes containing WrappedMessage #379

ryanemerson opened this issue Dec 6, 2024 · 1 comment

Comments

@ryanemerson
Copy link
Contributor

Reading JSON bytes will fail if the original Protobuf bytes contain a WrappedMessage.

var bytes = ProtobufUtil.toWrappedByteArray(ctx, new WrappedMessage(1), 512);
var json = ProtobufUtil.toCanonicalJSON(ctx, bytes);
var jsonBytes = ProtobufUtil.fromCanonicalJSON(ctx, new StringReader(json));

Throws:

java.lang.IllegalStateException: The field '_value' was not found in the Protobuf schema
	at org.infinispan.protostream.impl.JsonUtils.processObject(JsonUtils.java:256)
	at org.infinispan.protostream.impl.JsonUtils.processDocument(JsonUtils.java:150)
	at org.infinispan.protostream.impl.JsonUtils.fromCanonicalJSON(JsonUtils.java:89)
	at org.infinispan.protostream.ProtobufUtil.fromCanonicalJSON(ProtobufUtil.java:196)
@ryanemerson
Copy link
Contributor Author

It appears that the root cause of the issue is that the original JSON representation for a WrappedMessage does not contain sufficient information for the object to be recreated and will actually produce an invalid JSON object if the message contained within WrappedMessage consists of multiple fields.

For example, WrappedMessage(UUID) will result in the following invalid JSON being generated:

{"_type":"org.infinispan.protostream.WrappedMessage","_value":1005,"_value":"GdJNvZMpmrhJIVsBI+w5SN6O"}

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