-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
has-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issueIndicates that there exists a test case (under `failing/`) to reproduce the issuewill-not-fixClosed as either non-issue or something not planned to be worked onClosed as either non-issue or something not planned to be worked on
Description
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
If a property with a capitalized second letter (i.e. String aProp;) has a getter/setter whose name has not changed the prop name (i.e. getaProp() and setaProp()) the property will not be properly serialized/deserialized. This is true whether or not the mapper feature MapperFeature.FIX_FIELD_NAME_UPPER_CASE_PREFIX is enabled or disabled.
Version Information
3.0.0
Reproduction
public class TestPojo {
private String aProp;
private String anotherProp;
public String getaProp() {
return aProp;
}
public void setaProp(String aProp) {
this.aProp = aProp;
}
public String getAnotherProp() {
return anotherProp;
}
public void setAnotherProp(String anotherProp) {
this.anotherProp = anotherProp;
}
}
public void featureEnabledTest() {
ObjectMapper mapper = JsonMapper.builder().enable(MapperFeature.FIX_FIELD_NAME_UPPER_CASE_PREFIX).build();
String json = "{\"aProp\":\"aPropValue\", \"prop1\":\"prop1Value\"}";
TestPojo result = mapper.readValue(json, TestPojo.class);
assert "aPropValue".equals(result.getaProp()); //fails
String serialized = mapper.writeValueAsString(result);
assert serialized.equals(json);
}
public void featureDisabledTest() {
ObjectMapper mapper = JsonMapper.builder().disable(MapperFeature.FIX_FIELD_NAME_UPPER_CASE_PREFIX).build();
String json = "{\"aProp\":\"aPropValue\", \"prop1\":\"prop1Value\"}";
TestPojo result = mapper.readValue(json, TestPojo.class);
assert "aPropValue".equals(result.getaProp()); //fails
String serialized = mapper.writeValueAsString(result);
assert serialized.equals(json);
}Expected behavior
No response
Additional context
This was not an issue in 2.20.0, but has become one since migrating to 3.0.0.
Metadata
Metadata
Assignees
Labels
has-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issueIndicates that there exists a test case (under `failing/`) to reproduce the issuewill-not-fixClosed as either non-issue or something not planned to be worked onClosed as either non-issue or something not planned to be worked on