Skip to content

Add a Jackson 3 converter#4552

Open
sschuberth wants to merge 2 commits into
lysine-dev:trunkfrom
sschuberth:jackson3-converter
Open

Add a Jackson 3 converter#4552
sschuberth wants to merge 2 commits into
lysine-dev:trunkfrom
sschuberth:jackson3-converter

Conversation

@sschuberth

@sschuberth sschuberth commented Nov 5, 2025

Copy link
Copy Markdown

  • CHANGELOG.md's "Unreleased" section has been updated, if applicable.

@JakeWharton

Copy link
Copy Markdown
Collaborator

Thanks! This mostly looks good from a quick check.

I want to familiarize myself with this major release, but otherwise I hope to get this merged this month and released by EOY.

@sschuberth

Copy link
Copy Markdown
Author

I ran ./gradlew spotlessApply to address the linter issues and squashed the formatting fixes into the last commit.

@sschuberth

Copy link
Copy Markdown
Author

Mind approving the workflow once more to verify that tests now pass, @JakeWharton?

@sschuberth

Copy link
Copy Markdown
Author

Mind approving the workflow once more to verify that tests now pass, @JakeWharton?

I've rebased this to catch-up with the new required final-status check, but now running checks needs an approval again.

@sschuberth

Copy link
Copy Markdown
Author

I hope to get this merged this month and released by EOY.

Is there still a chance to get this merged before the end of the year?

@sschuberth

Copy link
Copy Markdown
Author

I hope to get this merged this month and released by EOY.

Is there still a chance to get this merged before the end of the year?

Happy new year ping 😉

@JakeWharton

Copy link
Copy Markdown
Collaborator

I have quit this company a few months ago so any work I do here is entirely volunteer work. I appreciate the contribution, but it'll still probably be a few weeks until I look at this project again.

@patschl

patschl commented Jan 16, 2026

Copy link
Copy Markdown

Hi! I'm also quite interested in this PR being merged. Is @JakeWharton the only maintainer of this project?

@JakeWharton

Copy link
Copy Markdown
Collaborator

The design of Retrofit is such that you do not need this to be merged to be unblocked. You can have your own Jackson 3 converter living in your codebase for the time being.

And yes, it's basically just me.

@sschuberth
sschuberth force-pushed the jackson3-converter branch 3 times, most recently from be1740e to 8b481ce Compare March 12, 2026 11:57

@danrebati-fujitsu danrebati-fujitsu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, though I am not a maintainer of this project. I'm just a passer-by 🙂

@sschuberth

Copy link
Copy Markdown
Author

Looks good to me, though I am not a maintainer of this project. I'm just a passer-by 🙂

Thanks anyway for the review, you had some good findings there!

@joanvr

joanvr commented Apr 15, 2026

Copy link
Copy Markdown

when is this planned to get merged and released?

This was implicitly available as a transitive dependency, but that
should not be relied on.

It is required for `JsonAutoDetect.Visibility.ANY`.

Note that `jackson-annotations` is versioned independently of the rest
of Jackson and does not use a path-level version suffix.
This mostly copies the existing Jackson (2) converter and does the
necessary migration [1]. Note that Jackson 3 requires Java 17.

[1]: https://github.com/FasterXML/jackson/blob/main/jackson3/MIGRATING_TO_JACKSON_3.md
@sschuberth
sschuberth force-pushed the jackson3-converter branch from 615e877 to d0459e6 Compare May 10, 2026 14:09
@jloisel

jloisel commented May 27, 2026

Copy link
Copy Markdown

Any update on this?

@pikmin86

Copy link
Copy Markdown

sorry to bother you @JakeWharton it seems (but i can be wrong) it only miss your approval to continue

@sschuberth

Copy link
Copy Markdown
Author

sorry to bother you @JakeWharton it seems (but i can be wrong) it only miss your approval to continue

Maybe this will move forward in the context of https://jakewharton.com/the-lysine-contingency/ 🙏🏻

}

try {
byte[] bytes = adapter.writeValueAsBytes(value);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion we can use a Buffer here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean like

ByteBuffer bytes = ByteBuffer.wrap(adapter.writeValueAsBytes(value));
return RequestBody.create(bytes.array(), mediaType);

Why, what's the advantage?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean okio.Buffer which reuses internal byte[]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I could do

ByteString bytes = ByteString.of(adapter.writeValueAsBytes(value));
return RequestBody.create(bytes, mediaType);

but I still don't see the benefit, esp. as I believe ByteString.of() copies the data underneath.

If you have a different proposal, please share the exact code.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a dev env of this repo so I can only provide following pseudo code.

var buffer = new okio.Buffer();
adapter.writeValue(buffer.outputStream(), value);
return RequestBody.create....

Like this: https://github.com/square/retrofit/blob/8e83a242eac1afc22a13c52098eddb27421353ff/retrofit-converters/gson/src/main/java/retrofit2/converter/gson/GsonRequestBodyConverter.java#L51-L53

But don't call readByteString at the end of it.

Use this (copied from my code):

private fun Buffer.asRequestBody(mediaType: MediaType) = object : RequestBody() {
    override fun contentType() = mediaType
    override fun contentLength(): Long = size
    override fun writeTo(sink: BufferedSink) {
        sink.writeAll(this@asRequestBody.copy()) // <- This is a shallow copy
    }
}

Well, if you want it to be simple you can ignore my comment.

@JakeWharton

Copy link
Copy Markdown
Collaborator

No features will be merged until the repo is moved. Yes it's taking forever to move.

@SinhaAmit

Copy link
Copy Markdown

Hi @JakeWharton, any timelines about this?

@JakeWharton

Copy link
Copy Markdown
Collaborator

No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

9 participants