Shared handling of Jackson-owned `Writer` over caller's `OutputStream` (non-UTF-8 generators, textual backends)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 38/100
Research direction
Start by reading TextualTSFactory.createGenerator(...), _createWriter(), and IOContext.encodingWriter() for the non-UTF-8 OutputStream, File, and Path paths; then compare the textual-backend handling described for GuardedOutputStream. Check existing generator flush/close behavior and tests for FLUSH_PASSED_TO_STREAM and AUTO_CLOSE_TARGET. Done means the shared handling proposal works consistently without flushing or closing the caller's stream when those features are disabled.
Written by the indexing model from the issue text.
Description
Follow-up to #1738 (part 2); #1739 added GuardedOutputStream.
Problem
For non-UTF-8 encodings, TextualTSFactory.createGenerator(ObjectWriteContext, OutputStream, JsonEncoding) wraps the caller's stream directly in an OutputStreamWriter (via _createWriter()), wrapped in IOContext.encodingWriter() (#1692). With both StreamWriteFeature.FLUSH_PASSED_TO_STREAM and AUTO_CLOSE_TARGET disabled:
gen.flush()does not get buffered content out: e.g. withUTF16_BE, afterwriteString("abc")+flush()the target has received 0 bytes (encoded content stays in theOutputStreamWriterbuffer)gen.close()drains content viaEncodingWriter.flushPending(), which callsOutputStreamWriter.flush()and thereby flushes the caller's stream, even thoughFLUSH_PASSED_TO_STREAMis disabled
The same applies to the File/Path generator paths using ioCtxt.encodingWriter(...).
Textual backends in jackson-dataformats-text (YAML, TOML, Properties) instead wrap the caller's stream in GuardedOutputStream, always flush/close their own Writer, and decide at flush/close time whether to flush/close the caller's stream. So JSON and those backends behave differently, and each backend generator duplicates the same flush/close branching.
Proposal
- In the non-UTF-8 paths, put
GuardedOutputStreamunder theOutputStreamWriterand keep a reference to the raw stream, so thatflush()always flushes the Jackson-ownedWriterand only flushes the caller's stream ifFLUSH_PASSED_TO_STREAMis enabled; similarly forclose()andAUTO_CLOSE_TARGET(orIOContext.isResourceManaged()). This should makeIOContext.EncodingWriterunnecessary. - Add a shared hook in
TextualTSFactoryand/or helper inGeneratorBasethat hands a generator both the Jackson-constructedWriterand the raw target, with the flush/close logic for that pair, so backends need not reimplement it.
🤖 Generated with Claude Code
- Dominant language
- Java
- Stars
- 2.4k
- Forks
- 952
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 32
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from FasterXML/jackson-core
-
Concurrent `BufferRecycler.releaseToPool()` calls can return the same recycler more than oncePossibly taken @Dongnyoung claimed this 5 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 70/100
FasterXML/jackson-core#1824 ·
Maintainers usually reply within 1 day
-
`UTF8DataInputJsonParser` reports end-of-input as `JacksonIOException` instead of `UnexpectedEndOfInputException`Possibly taken @curforever claimed this 34 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 57/100
FasterXML/jackson-core#1761 · 1 reaction ·
Maintainers usually reply within 1 day
-
`maxStringLength` is not enforced when skipping String valuesPossibly taken @Dongnyoung claimed this 39 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 75/100
FasterXML/jackson-core#1735 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Consider validating raw unpaired UTF-16 surrogates in ReaderBasedJsonParserPossibly taken @nvsaigokul-sudo claimed this 7 days ago. Open
Difficulty 5/5 Over a week Newbie friendliness 35/100
FasterXML/jackson-core#1705 · 5 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Non-root number separator validation not applied to non-blocking (async) parser (follow-up to #1557)Possibly taken @seonwooj0810 claimed this 98 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 68/100
FasterXML/jackson-core#1640 ·
Maintainers usually reply within 1 day
All issues in FasterXML/jackson-core
Similar issues
-
Cleanup: restore the interrupt flag in AiFailureAnalyzerPossibly taken @Rishankgupta08 claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
seleniumboot/selenium-boot#258 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
dense-analysis/ale#5181 ·
-
bug subsystem:agent-harness triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ShaftHQ/SHAFT_ENGINE#8043 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
johanhaleby/occurrent#1505 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day