Expected Behavior
byte[] can means 2 things.
- pass-through: do not serialize/deserialize the values. Sent/return the raw data. Other parts of the system will deal with raw data.
- normal byte[] values: serialize/deserialize them normally.
Actual Behavior
Current DaprObjectSerializer does not differentiate between pass-through byte[] and normal byte[] values. The DefaultObjectSerializer treats byte[] as always pass-through.
There are cases when serializing/deserializing byte[] as normal values is desired. For example, for json, it's desired to serialize byte[] as base64-encoded String because there's no other way to represent byte[] as legal JSON values.
I suggest to change the DaprObjectSerializer to follows:
public interface DaprObjectSerializer {
default byte[] serialize(Object o) throws IOException {
// passThrough by default true, to make this not a breaking change.
return serialize(o, true);
}
byte[] serialize(Object o, boolean passThrough) throws IOException;
default <T> T deserialize(byte[] data, TypeRef<T> type) throws IOException {
return deserialize(data, type, true);
}
<T> T deserialize(byte[] data, TypeRef<T> type, boolean passThrough) throws IOException;
String getContentType();
}
and DefaultObjectSerializer should be changed to honor explicit passThrough param.
Steps to Reproduce the Problem
Release Note
RELEASE NOTE:
Expected Behavior
byte[] can means 2 things.
Actual Behavior
Current DaprObjectSerializer does not differentiate between pass-through byte[] and normal byte[] values. The DefaultObjectSerializer treats byte[] as always pass-through.
There are cases when serializing/deserializing byte[] as normal values is desired. For example, for json, it's desired to serialize byte[] as base64-encoded String because there's no other way to represent byte[] as legal JSON values.
I suggest to change the DaprObjectSerializer to follows:
and DefaultObjectSerializer should be changed to honor explicit passThrough param.
Steps to Reproduce the Problem
Release Note
RELEASE NOTE: