FasterXML / jackson-dataformats-binary

Uber-project for standard Jackson binary format backends: avro, cbor, ion, protobuf, smile
Apache License 2.0
310 stars 133 forks source link

`IonFactory.createParser(IonReader)` does not initialize state #436

Open cowtowncoder opened 9 months ago

cowtowncoder commented 9 months ago

(note: issue uncovered when working on fix for #434)

It looks like following method in IonFactory

    public IonParser createParser(IonReader in) {
        ...
    }

does not initialize state according to current state of IonReader. This is fine for the common case of newly constructed IonReader (which does not point to anything); but does not work as expected in case IonReader has been advanced to point to a token. This seems like a flaw and there is at least one unit test that appears to expect this to work: test in question has been working due to many methods in IonParser not verifying current token and getting information directly from IonReader. But this will be problematic when checking for, say, IonParser.currentToken() since Jackson streaming level state information is not properly set up.

Ideally, current token and other settings would be properly initialized.