jackson-core
jackson-core copied to clipboard
`FilteringParserDelegate` can go into an infinite loop if underlying parser is non-blocking
Jackson version (BOM): 2.15.2
While experimenting with JsonPointer
in Spring Framework, I tried to build up on the existing FilteringParserDelegate
and associated JsonPointerBasedTokenFilter
. Unfortunately, this doesn't seem to work with a non-blocking JsonParser
delegate, for several reasons:
- it doesn't delegate method
canParseAsync()
(ends up returning the default interface implem =>false
) - it doesn't delegate method
getNonBlockingInputFeeder()
(same as above =>null
) - it isn't aware of
JsonToken.NOT_AVAILABLE
While the first two are easily circumvented by extending FilteringParserDelegate
, the last one is the truly problematic one. It results in going down the code path of a "scalar value", and will continuously call delegate.nextToken()
which continues to result in NOT_AVAILABLE
.
This leads to an infinite loop when attempting to filter based on a JsonPointer
on top of a non-blocking parser.
Is there anything fundamentally preventing FilteringParserDelegate
from being compatible with non-blocking parsers that I might have overlooked? Otherwise I think it's pretty close, hopefully that can be fixed 😄