FasterXML / FasterXML/jackson-dataformats-binary
IonFactory leaks stream when parser/generator construction fails for File/Path
- Lenguaje dominante
- Java
- Estrellas
- 347
- Forks
- 156
- Merge medio
- 3 d 3 h
- PR fusionados (30 d)
- 22
Descripción
`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`:
```java
// 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.com/claude-code)
https://claude.ai/code/session_01XrYRabZTvG9TjdXTCghvaM
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.