Skip to content
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
10 changes: 9 additions & 1 deletion release-notes/CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,15 @@ Oliver Drotbohm (@odrotbohm)
* Contributed fix for #4629: `@JsonIncludeProperties` and `@JsonIgnoreProperties`
ignored when deserializing Records
[3.1.0]

* Contributed fix for #5115: `@JsonUnwrapped` Record deserialization can't handle
name collision
[3.1.0]

Viktor Szathmáry (@phraktle)
* Reported #5115: `@JsonUnwrapped` Record deserialization can't handle name collision
(reported by Viktor S)
[3.1.0]

Hélios Gilles (@RoiSoleil)
* Contributed #5413: Add/support forward reference resolution for array values
[3.1.0]
Expand Down
3 changes: 3 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Versions: 3.x (for earlier see VERSION-2.x)
creator property" when deserializing JSON with dup property to single-property Record
(reported by @sseelmann)
(fix contributed by @JacksonJang)
#5115: `@JsonUnwrapped` Record deserialization can't handle name collision
(reported by Viktor S)
(fix contributed by @JacksonJang)
#5184: `@JsonIgnore` on record method applied to record matching field
at deserialization
(reported by @emouty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1054,33 +1054,38 @@ private void _addCreatorParams(Map<String, POJOPropertyBuilder> props,
final PropertyName explName = ctor.explicitName(i);
PropertyName implName = ctor.implicitName(i);
final boolean hasExplicit = (explName != null);
final POJOPropertyBuilder prop;

// neither implicit nor explicit name?
if (!hasExplicit && (implName == null)) {
boolean isUnwrapping = _annotationIntrospector.findUnwrappingNameTransformer(_config, param) != null;
final boolean hasImplicit = (implName != null);

if (isUnwrapping) {
// First: check "Unwrapped" unless explicit name
if (!hasExplicit) {
var unwrapper = _annotationIntrospector.findUnwrappingNameTransformer(_config, param);
if (unwrapper != null) {
// If unwrapping, can use regardless of name; we will use a placeholder name
// anyway to try to avoid name conflicts.
PropertyName name = UnwrappedPropertyHandler.creatorParamName(param.getIndex());
prop = _property(props, name);
final POJOPropertyBuilder prop = _property(props, name);
prop.addCtor(param, name, false, true, false);
} else {
creatorProps.add(prop);
continue;
}
if (!hasImplicit) {
// Without name, cannot make use of this creator parameter -- may or may not
// be a problem, verified at a later point.
prop = null;
creatorProps.add(null);
continue;
}
}

// 27-Dec-2019, tatu: [databind#2527] may need to rename according to field
final POJOPropertyBuilder prop;
if (hasImplicit) {
String n = _checkRenameByField(implName.getSimpleName());
implName = PropertyName.construct(n);
prop = _property(props, implName);
} else {
// 27-Dec-2019, tatu: [databind#2527] may need to rename according to field
if (implName != null) {
String n = _checkRenameByField(implName.getSimpleName());
implName = PropertyName.construct(n);
}
prop = (implName == null)
? _property(props, explName) : _property(props, implName);
prop.addCtor(param, hasExplicit ? explName : implName, hasExplicit, true, false);
prop = _property(props, explName);
}
prop.addCtor(param, hasExplicit ? explName : implName, hasExplicit, true, false);
creatorProps.add(prop);
}
ctor.assignPropertyDefs(creatorProps);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package tools.jackson.databind.records.tofix;
package tools.jackson.databind.records;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.JsonUnwrapped;

import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.testutil.DatabindTestUtil;
import tools.jackson.databind.testutil.failure.JacksonTestFailureExpected;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand Down Expand Up @@ -62,7 +62,6 @@ void unwrappedRecordShouldRoundTripPass() throws Exception
assertEquals(input, output);
}

@JacksonTestFailureExpected
@Test
void unwrappedRecordShouldRoundTrip() throws Exception
{
Expand Down