Skip to content

Declare jackson-core and jackson-annotations next to jackson-databind - #46

Closed
PetrHeinz wants to merge 1 commit into
claude/logback-provided-scopefrom
claude/jackson-alignment
Closed

PetrHeinz wants to merge 1 commit into
claude/logback-provided-scopefrom
claude/jackson-alignment

Conversation

@PetrHeinz

@PetrHeinz PetrHeinz commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Stacked on #40. With jackson-databind 2.22.3 as the only Jackson dependency, Maven's nearest-first resolution takes jackson-core and jackson-annotations from any other Jackson module the application declares, because databind's own sit one level deeper. A project that declares logback-logtail and then jackson-datatype-jsr310 2.13.5 (for <objectMapperModule>com.fasterxml.jackson.datatype.jsr310.JavaTimeModule</objectMapperModule>, which the examples use) but not jackson-databind got databind 2.22.3 with core and annotations 2.13.5: logback printed "Could not create an Appender of type [com.logtail.logback.LogtailAppender]" (NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonSerializeAs), the application kept running and nothing was sent. With jackson-datatype-jdk8 2.13.5 instead, the appender was created and every flush died with NoSuchMethodError: BufferRecycler.releaseToPool(). With 0.3.8 and 0.3.9 (databind 2.13.5) the jsr310 project sends everything.

  • jackson-core 2.22.3 and jackson-annotations 2.22, the versions databind 2.22.3 depends on, are now declared next to it. They are as near as any other module's and win when logback-logtail is declared first. Only the POM changes; the class files are identical.
  • Trade-off: a project that declares an older jackson-databind itself after logback-logtail, as the docs' dependency block does with 2.13.5, now gets core and annotations 2.22 under its databind instead of matching versions. Jackson keeps core and annotations backward compatible: with databind 2.12.7, 2.13.5 and 2.17.3 on core 2.22.3 the example app sends everything, and a check of the application's own Jackson use (data binding, trees, convertValue, streaming, java.time) passes. Core 2.22 does bring its default processing limits to that application's own parsing (nesting depth 1000, numbers up to 1000 digits, strings up to 20M characters), which core 2.13.5 did not have. Declaring databind before logback-logtail, or importing jackson-bom, keeps matching versions.
  • Unchanged, and broken with Leave the logback version to the application, update dependencies #40 alone too: a project that declares an older jackson-core itself but not databind keeps its core, since a direct declaration always wins, so databind 2.22.3 runs on core 2.13.5 and every flush fails (0.3.9 resolved matching 2.13.5 there). Only the application can fix that, by declaring databind at the same version or importing jackson-bom.
  • Gradle aligns all Jackson modules through the jackson-bom platform in databind's Gradle module metadata: both Gradle projects below resolved 2.22.x, before and after.

Measured with the example app (7 lines, plain java -cp on JDK 21) against a Better Stack source, rows queried back. logback-logtail 0.4.0 = main + #40, without and with this change; versions are databind / core / annotations:

Maven project, dependencies in declaration order #40 #40 + this PR
logback-logtail, logback 1.5.38 2.22.3 / 2.22.3 / 2.22: 7/7 same: 7/7
logback-logtail, logback 1.2.11, databind 2.13.5 (docs block) 2.13.5 / 2.13.5 / 2.13.5: 7/7 2.13.5 / 2.22.3 / 2.22: 7/7
same with databind 2.12.7 2.12.7 / 2.12.7 / 2.12.7: 7/7 2.12.7 / 2.22.3 / 2.22: 7/7
databind 2.13.5 before logback-logtail 2.13.5 / 2.13.5 / 2.13.5: 7/7 same: 7/7
logback-logtail, databind + jsr310 2.13.5 (0.3.8 examples) 2.13.5 / 2.13.5 / 2.13.5: 7/7 2.13.5 / 2.22.3 / 2.22: 7/7
logback-logtail, jsr310 2.13.5, no databind 2.22.3 / 2.13.5 / 2.13.5: 0/7, no appender 2.22.3 / 2.22.3 / 2.22: 7/7
jsr310 2.13.5 before logback-logtail, no databind 2.13.5 / 2.13.5 / 2.13.5: 7/7 same: 7/7
logback-logtail, jdk8 2.13.5, no databind 2.22.3 / 2.13.5 / 2.22: 0/7, flush fails 2.22.3 / 2.22.3 / 2.22: 7/7
logback-logtail, databind + jsr310 2.17.3 2.17.3 / 2.17.3 / 2.17.3: 7/7 2.17.3 / 2.22.3 / 2.22: 7/7
logback-logtail, jackson-core 2.13.5, no databind 2.22.3 / 2.13.5 / 2.22: 0/7, flush fails same: 0/7
Gradle: docs block, and jsr310 2.13.5 without databind 2.22.3 / 2.22.3 / 2.22: 7/7 same: 7/7

To land it: merge this into #40's branch before squash-merging #40, or retarget it to main once #40 is merged.

🤖 Generated with Claude Code

With databind 2.22.3 as the only Jackson dependency, Maven's nearest-first
resolution took jackson-core and jackson-annotations from any other Jackson
module an application declares, since databind's own sit one level deeper.
A project declaring logback-logtail and then jackson-datatype-jsr310 2.13.5
(for the JavaTimeModule the examples register) but not databind got databind
2.22.3 with core and annotations 2.13.5: logback could not create the
appender (NoClassDefFoundError: JsonSerializeAs) and no logs were sent. With
jackson-datatype-jdk8 2.13.5 instead, the appender was created and every
flush died with NoSuchMethodError in BufferRecycler.

Declaring core 2.22.3 and annotations 2.22, the versions databind 2.22.3
depends on, puts them as near as any other module's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PetrHeinz

Copy link
Copy Markdown
Member Author

Closing: keeping #40's POM with jackson-databind only (the usual pattern, e.g. logstash-logback-encoder); Jackson alignment (jackson-bom) goes into the 0.4.0 release notes and docs instead.

@PetrHeinz PetrHeinz closed this Sep 29, 2026
@PetrHeinz
PetrHeinz deleted the claude/jackson-alignment branch October 1, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant