IonFactory extends DecorableTSFactory directly (it can use either textual or binary format), so it does not inherit the File/Path create methods from TextualTSFactory/BinaryTSFactory — and therefore not the leak fix from FasterXML/jackson-core#1693 either. Its own copies open the stream and hand it off with no try/catch:
// IonFactory.java:252
public JsonParser createParser(ObjectReadContext readCtxt, File f) {
final InputStream in = _fileInputStream(f);
IOContext ioCtxt = _createContext(_createContentReference(f), true);
return _createParser(readCtxt, ioCtxt, _decorate(ioCtxt, in));
}
Anything that throws after the open — a user InputDecorator, or _createParser itself — leaks the file descriptor. Also note _fileInputStream(f) runs before _createContext(...), so a failure in _createContext leaks too; jackson-core opens the stream after.
Affects createParser(File) (:252), createParser(Path) (:260), and on the generator side createGenerator(File, JsonEncoding) (:358) and createGenerator(Path, JsonEncoding) (:366), which are the equivalent of FasterXML/jackson-core#1692.
Fix is the same shape as jackson-core: create the IOContext first, then open inside a try, and route RuntimeException through DecorableTSFactory._closeOnFailedConstruction(Closeable, RuntimeException) — protected as of jackson-core 3.1, so IonFactory can call it directly.
Every other backend (Smile, CBOR, Avro, Protobuf, XML, YAML, CSV) inherits the base-class methods and is already covered; Ion is the only one that opts out.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XrYRabZTvG9TjdXTCghvaM
IonFactoryextendsDecorableTSFactorydirectly (it can use either textual or binary format), so it does not inherit theFile/Pathcreate methods fromTextualTSFactory/BinaryTSFactory— and therefore not the leak fix from FasterXML/jackson-core#1693 either. Its own copies open the stream and hand it off with notry/catch:Anything that throws after the open — a user
InputDecorator, or_createParseritself — leaks the file descriptor. Also note_fileInputStream(f)runs before_createContext(...), so a failure in_createContextleaks too; jackson-core opens the stream after.Affects
createParser(File)(:252),createParser(Path)(:260), and on the generator sidecreateGenerator(File, JsonEncoding)(:358) andcreateGenerator(Path, JsonEncoding)(:366), which are the equivalent of FasterXML/jackson-core#1692.Fix is the same shape as jackson-core: create the
IOContextfirst, then open inside atry, and routeRuntimeExceptionthroughDecorableTSFactory._closeOnFailedConstruction(Closeable, RuntimeException)—protectedas of jackson-core 3.1, soIonFactorycan call it directly.Every other backend (Smile, CBOR, Avro, Protobuf, XML, YAML, CSV) inherits the base-class methods and is already covered; Ion is the only one that opts out.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XrYRabZTvG9TjdXTCghvaM