Skip to content

Commit 6cf2bb5

Browse files
Fix for lost annotations
1 parent b6f3f6a commit 6cf2bb5

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,28 +683,28 @@ public void mergeAnnotations(boolean forSerialization)
683683
if (forSerialization) {
684684
if (_getters != null) {
685685
AnnotationMap ann = _mergeAnnotations(0, _getters, _fields, _ctorParameters, _setters);
686-
_getters = _getters.withValue(_getters.value.withAnnotations(ann));
686+
_getters = _applyAnnotations(_getters, ann);
687687
} else if (_fields != null) {
688688
AnnotationMap ann = _mergeAnnotations(0, _fields, _ctorParameters, _setters);
689-
_fields = _fields.withValue(_fields.value.withAnnotations(ann));
689+
_fields = _applyAnnotations(_fields, ann);
690690
}
691691
} else { // for deserialization
692692
if (_ctorParameters != null) {
693693
AnnotationMap ann = _mergeAnnotations(0, _ctorParameters, _setters, _fields, _getters);
694-
_ctorParameters = _ctorParameters.withValue(_ctorParameters.value.withAnnotations(ann));
694+
_ctorParameters = _applyAnnotations(_ctorParameters, ann);
695695
} else if (_setters != null) {
696696
AnnotationMap ann = _mergeAnnotations(0, _setters, _fields, _getters);
697-
_setters = _setters.withValue(_setters.value.withAnnotations(ann));
697+
_setters = _applyAnnotations(_setters, ann);
698698
} else if (_fields != null) {
699699
AnnotationMap ann = _mergeAnnotations(0, _fields, _getters);
700-
_fields = _fields.withValue(_fields.value.withAnnotations(ann));
700+
_fields = _applyAnnotations(_fields, ann);
701701
}
702702
}
703703
}
704704

705705
private AnnotationMap _mergeAnnotations(int index, Linked<? extends AnnotatedMember>... nodes)
706706
{
707-
AnnotationMap ann = nodes[index].value.getAllAnnotations();
707+
AnnotationMap ann = _getAllAnnotations(nodes[index]);
708708
++index;
709709
for (; index < nodes.length; ++index) {
710710
if (nodes[index] != null) {
@@ -713,7 +713,23 @@ private AnnotationMap _mergeAnnotations(int index, Linked<? extends AnnotatedMem
713713
}
714714
return ann;
715715
}
716-
716+
717+
private <T extends AnnotatedMember> AnnotationMap _getAllAnnotations(Linked<T> node) {
718+
AnnotationMap ann = node.value.getAllAnnotations();
719+
if (node.next != null) {
720+
ann = AnnotationMap.merge(ann, _getAllAnnotations(node.next));
721+
}
722+
return ann;
723+
}
724+
725+
private <T extends AnnotatedMember> Linked<T> _applyAnnotations(Linked<T> node, AnnotationMap ann) {
726+
T value = (T) node.value.withAnnotations(ann);
727+
if (node.next != null) {
728+
node = node.withNext(_applyAnnotations(node.next, ann));
729+
}
730+
return node.withValue(value);
731+
}
732+
717733
private <T> Linked<T> _removeIgnored(Linked<T> node)
718734
{
719735
if (node == null) {

0 commit comments

Comments
 (0)