FasterXML / FasterXML/jackson-dataformats-binary
IonFactory leaks stream when parser/generator construction fails for File/Path
- 主要言語
- Java
- スター
- 347
- フォーク
- 156
- 平均マージ
- 3日 3時間
- マージ済み PR(30日)
- 22
説明
`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
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。