Assuming I have the following object
public class DataObjectA {
private Stream dataObjectBStream;
}
How can I serial
See https://github.com/FasterXML/jackson-modules-java8/issues/3 for the open issue to add java.util.Stream
support to Jackson. There's a preliminary version of the code included. (edit: this is now merged and supported in 2.9.0).
Streaming support feels like it would work naturally/safely if the stream is the top level object you were (de)serializing, eg returning a java.util.stream.Stream
from a JAX-RS resource, or reading a Stream
from a JAX-RS client.
A Stream as a member variable of a (de)serialized object, as you have in your example, is trickier, because it's mutable and single use:
private Stream
;dataObjectBStream
Assuming it was supported, all of the caveats around storing references to streams would apply. You wouldn't be able to serialize the object more than once, and once you deserialized the wrapping object presumably it's stream member would retain a live connection back through the JAX-RS client and HTTP connection, which could create surprises.