You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As part of SPR-16151 and due to various users asking such support, we try to support Smile Async streaming in the upcoming Spring Framework 5.0.3, in a similar fashion we currently support JSON Async streaming.
I have done various changes to support that, but my integration tests with serialization/deserialization of 2 POJOs generates the following error:
JSON: com.fasterxml.jackson.core.JsonParseException: Still have 21 undecoded bytes, should not call 'feedInput' at [Source: UNKNOWN; line: -1, column: 18]
Data are concatenated without separator.
Could you please check if this use case is currently supported, and if not support it?
Thanks, hope to look into this soon. I can first verify if this is tested or not; and if not, try to think of what the conceptual limitations might be (if any).
@sdeleuze haven't had a chance, but should have time week. Thanks for reminder.
I am planning on getting 2.9.4 release out sometime in January, due to some important (some for unexpected backwards compatibility issues, others for minor improvements wrt security handling for CVEs). So evaluating this should occur before that release.
I guess it would be really useful if there was a bit more isolated test, basically taking active calls into a unit test to show the problem. I assume that things work with both json and smile with regular blocking i/o, and individual objects via async for both as well. But that sequence of multiple object not so much with Smile.
@sdeleuze Ah. I may know what is going on here. Brief version is that between Smile documents -- ones separated by header bytes and/or end marker, will return null token to indicate end of document. This does NOT necessarily indicate end of the whole stream, but rather that there is document boundary. To test if stream is done there are couple of ways; either getting another null, or, perhaps better, see if parser.isClosed() returns true. Or best maybe, needMoreInput (of NonBlockingInputFeeder) which indicates there is content to decode.
JSON, on the other hand, has no means for indicating document boundaries.
It is also possible, actually, to create Smile document "streams" without boundaries, if neither header nor end-marker is output. Such content would be exposed without intervening null tokens.
I am not sure what to think of this discrepancy: it is not ideal, obviously, but at the same time it does reflect actual difference between formats, as Smile has bit more metadata.
But in practical terms I think behavior can not be changed since this is part of API at this point -- as far as I can see this is not special for async API but would work same way on blocking API too.
Yes that makes sense, thank for your guidance, I will update our implementation accordingly. I will close this issue after checking it works as expected with parser.isClosed() or needMoreInput.
@sdeleuze Thanks. Good catch, sorry it took so long for me to take a look. Good thing is that there was a test for root value handling, wrt separate documents. I may need to additionally consider use with the alternative of appending root-level values without closing stream (or, disabling start and end marker), which is represented differently but should still work without exceptions or failures (but omitting null marker in stream).
@sdeleuze Ok. Yeah, probably isClosed() can't work with async the same way, without caller actually indicating "no more input" at point where needsMoreInput() would be true.
The intended logic is, I think, that needsMoreInput() only returns true after consuming all input being given. So if this is the case (returns true) AND there is no more input to feed, then there can not be more to read. But double-null is probably the best way at this point, simplest, should work.
Activity
cowtowncoder commentedon Dec 18, 2017
Thanks, hope to look into this soon. I can first verify if this is tested or not; and if not, try to think of what the conceptual limitations might be (if any).
sdeleuze commentedon Jan 8, 2018
Hey, any chance to have a look on this one in order to allow us to support Smile streaming in our upcoming 5.0.4 release expected on February 15th?
cowtowncoder commentedon Jan 8, 2018
@sdeleuze haven't had a chance, but should have time week. Thanks for reminder.
I am planning on getting
2.9.4release out sometime in January, due to some important (some for unexpected backwards compatibility issues, others for minor improvements wrt security handling for CVEs). So evaluating this should occur before that release.sdeleuze commentedon Jan 9, 2018
Thanks for the heads up.
cowtowncoder commentedon Jan 10, 2018
I guess it would be really useful if there was a bit more isolated test, basically taking active calls into a unit test to show the problem. I assume that things work with both json and smile with regular blocking i/o, and individual objects via async for both as well. But that sequence of multiple object not so much with Smile.
sdeleuze commentedon Jan 12, 2018
Please find a minimal repro use case in this repository. The same test works with JSON but fails with Smile.
cowtowncoder commentedon Jan 26, 2018
@sdeleuze Ah. I may know what is going on here. Brief version is that between Smile documents -- ones separated by header bytes and/or end marker, will return
nulltoken to indicate end of document. This does NOT necessarily indicate end of the whole stream, but rather that there is document boundary. To test if stream is done there are couple of ways; either getting anothernull, or, perhaps better, see ifparser.isClosed()returnstrue. Or best maybe,needMoreInput(ofNonBlockingInputFeeder) which indicates there is content to decode.JSON, on the other hand, has no means for indicating document boundaries.
It is also possible, actually, to create Smile document "streams" without boundaries, if neither header nor end-marker is output. Such content would be exposed without intervening
nulltokens.I am not sure what to think of this discrepancy: it is not ideal, obviously, but at the same time it does reflect actual difference between formats, as Smile has bit more metadata.
But in practical terms I think behavior can not be changed since this is part of API at this point -- as far as I can see this is not special for async API but would work same way on blocking API too.
Does this make sense?
sdeleuze commentedon Jan 27, 2018
Yes that makes sense, thank for your guidance, I will update our implementation accordingly. I will close this issue after checking it works as expected with
parser.isClosed()orneedMoreInput.cowtowncoder commentedon Jan 28, 2018
@sdeleuze Thanks. Good catch, sorry it took so long for me to take a look. Good thing is that there was a test for root value handling, wrt separate documents. I may need to additionally consider use with the alternative of appending root-level values without closing stream (or, disabling start and end marker), which is represented differently but should still work without exceptions or failures (but omitting
nullmarker in stream).sdeleuze commentedon Jan 29, 2018
FYI it works only when checking double
null, other methods don't work.cowtowncoder commentedon Jan 29, 2018
@sdeleuze Ok. Yeah, probably
isClosed()can't work with async the same way, without caller actually indicating "no more input" at point whereneedsMoreInput()would betrue.The intended logic is, I think, that
needsMoreInput()only returnstrueafter consuming all input being given. So if this is the case (returnstrue) AND there is no more input to feed, then there can not be more to read. But double-null is probably the best way at this point, simplest, should work.sdeleuze commentedon Jan 30, 2018
Yes I chose the double-null path, thanks for your feedback, Smile streaming will be supported in Spring Framework 5.0.4.
cowtowncoder commentedon Jan 30, 2018
Excellent, I saw the announcement. This is great, thank you!