Skip to content

Commit 6d5e2ba

Browse files
committed
Minor fix to JacksonAnnotationIntrospector to allow use of @JsonSetter without masking name
1 parent df28f61 commit 6d5e2ba

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,16 +1228,23 @@ public JsonPOJOBuilder.Value findPOJOBuilderConfig(AnnotatedClass ac)
12281228
public PropertyName findNameForDeserialization(Annotated a)
12291229
{
12301230
// @JsonSetter has precedence over @JsonProperty, being more specific
1231-
// @JsonDeserialize implies that there is a property, but no name
1231+
1232+
boolean useDefault = false;
12321233
JsonSetter js = _findAnnotation(a, JsonSetter.class);
12331234
if (js != null) {
1234-
return PropertyName.construct(js.value());
1235+
String s = js.value();
1236+
// 04-May-2018, tatu: Need to allow for "nameless" `@JsonSetter` too
1237+
if (s.isEmpty()) {
1238+
useDefault = true;
1239+
} else {
1240+
return PropertyName.construct(s);
1241+
}
12351242
}
12361243
JsonProperty pann = _findAnnotation(a, JsonProperty.class);
12371244
if (pann != null) {
12381245
return PropertyName.construct(pann.value());
12391246
}
1240-
if (_hasOneOf(a, ANNOTATIONS_TO_INFER_DESER)) {
1247+
if (useDefault || _hasOneOf(a, ANNOTATIONS_TO_INFER_DESER)) {
12411248
return PropertyName.USE_DEFAULT;
12421249
}
12431250
return null;

0 commit comments

Comments
 (0)