Skip to content

Adapt Jackson2ObjectMapperBuilder documentation to mention ParameterNamesModule registration #31959

@lbenedetto

Description

@lbenedetto

After updating to 3.2.x, deserialization seems to be broken in my project. Here is some simple code to reproduce.

Given a class:

import java.beans.ConstructorProperties; import org.springframework.lang.NonNull; import lombok.EqualsAndHashCode; import lombok.Value; @Value @EqualsAndHashCode(callSuper = false) public class TestClass { @ConstructorProperties("value") public TestClass(String somethingElse) { System.out.println("Got value: " + somethingElse); this.value = somethingElse; } @NonNull String value; }

And a unit test:

 @Test void testCountryId() throws Exception { // Given var object = new TestClass("test"); var mapper = new Jackson2ObjectMapperBuilder().build(); // When var toString = mapper.writeValueAsString(object); var fromString = mapper.readValue(toString, TestClass.class); // Then then(fromString).isEqualTo(object); }

The test passes in both versions (in my actual project it fails because the value cannot be null), but

When running the unit test with Spring 3.2, it will print:

Got value: test Got value: null 

However, when running the unit test with Spring 3.1, it will print:

Got value: test Got value: test 

If I change the constructor parameter name from somethingElse to value then 3.2 prints the same as 3.1.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions