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
Describe the bug
I try to fix the ticket #611 and write the tests, which would test every method of the underlying YassonParser. The issue that I found: if you use getObjectStream() for example, you can't go past the end of the object you are inside. The parser state is then broken. It doesn't matter which kind of stream methods you are using, all consuming like collect() or just findFirst() to get the first one.
To Reproduce
The reason: we return the stream from delegate but assuming, already before, that the whole object was consumed and lowering the current internal level. But especially in case of the getObjectStream() one can't reach the end of the object using the stream methods itself. So one have to use skipObject() to get to the end of the object, lowering the internal level value to zero. Trying to get the next value, one gets an exception from the validate() method.
Analyzing the situation, a discovered more probably issues. First, all of this stream methods simply returns the according streams from the underlying JsonP parser. Now if one uses this stream, one changes the state of this underlying parser, but YassonParser itself state doesn't change. The bug above is one of examples of such desynchronization.
On the other hand, this parser maintains the last event state in the given context by using setLastValueEvent() method. This is clearly not happens in case of the stream using and the skip methods.
Expected behavior
I expect to use stream methods without any side effects
System information:
OS: Linux
Java Version: 17
Yasson Version: 3.0.3
Additional context
I'll create a patch: I already implemented the stream methods in the JsonStructureToParserAdapter #625, where they were missed. The implementation using the hasNext(), next() and getValue() methods of the parser. I'll extract this code into a class which could create such streams for any given parser. And correct the skip methods; and write the test for all of this, so the code coverage of the YassonParser will reach 100%.
The text was updated successfully, but these errors were encountered:
Describe the bug
I try to fix the ticket #611 and write the tests, which would test every method of the underlying YassonParser. The issue that I found: if you use getObjectStream() for example, you can't go past the end of the object you are inside. The parser state is then broken. It doesn't matter which kind of stream methods you are using, all consuming like collect() or just findFirst() to get the first one.
To Reproduce
The reason: we return the stream from delegate but assuming, already before, that the whole object was consumed and lowering the current internal level. But especially in case of the getObjectStream() one can't reach the end of the object using the stream methods itself. So one have to use skipObject() to get to the end of the object, lowering the internal level value to zero. Trying to get the next value, one gets an exception from the validate() method.
Analyzing the situation, a discovered more probably issues. First, all of this stream methods simply returns the according streams from the underlying JsonP parser. Now if one uses this stream, one changes the state of this underlying parser, but YassonParser itself state doesn't change. The bug above is one of examples of such desynchronization.
On the other hand, this parser maintains the last event state in the given context by using setLastValueEvent() method. This is clearly not happens in case of the stream using and the skip methods.
Expected behavior
I expect to use stream methods without any side effects
System information:
Additional context
I'll create a patch: I already implemented the stream methods in the JsonStructureToParserAdapter #625, where they were missed. The implementation using the hasNext(), next() and getValue() methods of the parser. I'll extract this code into a class which could create such streams for any given parser. And correct the skip methods; and write the test for all of this, so the code coverage of the YassonParser will reach 100%.
The text was updated successfully, but these errors were encountered: