Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues 4697 and 2461 (@JsonUnwrapped caching) #4722

Merged
merged 8 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,13 @@ Maxim Valeev (@MaximValeev)
* Reported #4508: Deserialized JsonAnySetter field in Kotlin data class is null
(2.18.1)

@SandeepGaur2016

* Contributed fix for #2461: Nested `@JsonUnwrapped` property names not correctly handled
(2.19.0)
* Contributed fix for #4697: Inconsistent serialization with `@JsonUnwrapped` annotation
using shared vs. new `ObjectMapper` instances
(2.19.0)

Lars Benedetto (@lbenedetto)
* Contributed #4676: Support other enum naming strategies than camelCase
Expand Down
8 changes: 7 additions & 1 deletion release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ Project: jackson-databind

2.19.0 (not yet released)

#2461: Nested `@JsonUnwrapped` property names not correctly handled
(reported by @plovell)
(fix contributed by @SandeepGaur2016)
#4676: Support other enum naming strategies than camelCase
(requested by @hajdamak)
(contributed by Lars B)
(contributed by Lars
#4697: Inconsistent serialization with `@JsonUnwrapped` annotation
using shared vs. new `ObjectMapper` instances
(fix contributed by @SandeepGaur2016)

2.18.1 (WIP-2024)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ public BeanPropertyWriter(BeanPropertyDefinition propDef,

_declaredType = declaredType;
_serializer = (JsonSerializer<Object>) ser;
_dynamicSerializers = (ser == null) ? PropertySerializerMap
.emptyForProperties() : null;
_dynamicSerializers = (ser == null) ? PropertySerializerMap.emptyForProperties() : null;
_typeSerializer = typeSer;
_cfgSerializationType = serType;

Expand Down Expand Up @@ -325,7 +324,7 @@ protected BeanPropertyWriter(BeanPropertyWriter base, PropertyName name) {
base._internalSettings);
}
_cfgSerializationType = base._cfgSerializationType;
_dynamicSerializers = base._dynamicSerializers;
_dynamicSerializers = PropertySerializerMap.emptyForProperties();
_suppressNulls = base._suppressNulls;
_suppressableValue = base._suppressableValue;
_includeInViews = base._includeInViews;
Expand All @@ -350,7 +349,7 @@ protected BeanPropertyWriter(BeanPropertyWriter base, SerializedString name) {
base._internalSettings);
}
_cfgSerializationType = base._cfgSerializationType;
_dynamicSerializers = base._dynamicSerializers;
_dynamicSerializers = PropertySerializerMap.emptyForProperties();
_suppressNulls = base._suppressNulls;
_suppressableValue = base._suppressableValue;
_includeInViews = base._includeInViews;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ public Third() {
}
}

public static class AnotherFirst {
public Third thrid = new Third();
}

public static class Common {
public String a;
public String b;
public Common() {}
}

@JacksonTestFailureExpected
@Test
public void testInconsistentSer() throws Exception {
First first = new First();
Expand All @@ -51,8 +54,23 @@ public void testInconsistentSer() throws Exception {
ObjectMapper secondMapper = newJsonMapper();

firstMapper.writeValueAsString(first);
firstMapper.writeValueAsString(second);
assertEquals(
firstMapper.writeValueAsString(second),
secondMapper.writeValueAsString(second));
}
@Test
public void testInconsistentSer1() throws Exception {
AnotherFirst first = new AnotherFirst();
Second second = new Second();

ObjectMapper firstMapper = newJsonMapper();
ObjectMapper secondMapper = newJsonMapper();

firstMapper.writeValueAsString(first);
firstMapper.writeValueAsString(second);
assertEquals(
firstMapper.writeValueAsString(second),
secondMapper.writeValueAsString(second));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ static class OuterContainer {
}

// [databind#2461]
@JacksonTestFailureExpected
@Test
void unwrappedCaching() throws Exception {
final InnerContainer inner = new InnerContainer(new Base("12345"));
Expand Down