jackson-core
jackson-core copied to clipboard
Add a set of "withParser(...)" and "withGenerator(...)" methods in `TokenStreamFactory` for auto-close
Currently createParser()
and createGenerator()
methods require caller to take care of closing of parser/generator, allowing possible loss of things like file handles and URL connections (see #803 f.ex)
But it would be easy to add a complementary set of methods that would be similar to matching "createXxx()" methods but take an additional closure, callback to which parser/generator would be passed and which could return a value (like object bound with readValue()
).
Although we could technically add this in 2.x (since Java 8 is now the baseline with 2.14), it seems that for backwards-compatibility reasons this is better for 3.x when jackson-databind
can make good use of the new functionality.