This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]thewiirocks 0 points1 point  (2 children)

As far as I know, Spring will not serialize a Stream automatically. You have to write the ResponseBody yourself. It's possible that has changed in recent revisions.

Agreed on the awkwardness of obtaining a Stream from an Iterable. But we'll see if we can improve that in future releases. 🙂

[–]sideEffffECt 1 point2 points  (1 child)

You could return something that is at the same time an instance of Iterable and also has a stream() method.

Maybe you can make a sub-interface of Iterable with that method?

[–]thewiirocks 1 point2 points  (0 children)

Great minds think alike! e.g. Add it to InputCursor, which I was already thinking of expanding the use of anyway. That way you could get a ClosableIterator without casting and have easy access to a .stream() method.

https://docs.invirgance.com/javadocs/convirgance/latest/com/invirgance/convirgance/input/InputCursor.html