Skip to content

Commit 9b530bf

Browse files
committed
Merge branch '2.4'
Conflicts: src/test/java/com/fasterxml/jackson/databind/introspect/TestMixinMerging.java
2 parents 62425ef + fd0f1fe commit 9b530bf

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public final class AnnotatedClass
1313
extends Annotated
1414
{
1515
private final static AnnotationMap[] NO_ANNOTATION_MAPS = new AnnotationMap[0];
16-
16+
1717
/*
1818
/**********************************************************
1919
/* Configuration
@@ -654,7 +654,13 @@ protected void _addMethodMixIns(Class<?> targetClass, AnnotatedMethodMap methods
654654
* just placeholder, can't be called)
655655
*/
656656
} else {
657-
mixIns.add(_constructMethod(m));
657+
// Well, or, as per [Issue#515], multi-level merge within mixins...
658+
am = mixIns.find(m);
659+
if (am != null) {
660+
_addMixUnders(m, am);
661+
} else {
662+
mixIns.add(_constructMethod(m));
663+
}
658664
}
659665
}
660666
}
Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,50 @@
11
package com.fasterxml.jackson.databind.introspect;
22

3-
import com.fasterxml.jackson.databind.BaseMapTest;
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
import com.fasterxml.jackson.databind.*;
6+
import com.fasterxml.jackson.databind.module.SimpleModule;
47

58
public class TestMixinMerging extends BaseMapTest
69
{
10+
public interface Contact {
11+
String getCity();
12+
}
13+
14+
static class ContactImpl implements Contact {
15+
public String getCity() { return "Seattle"; }
16+
}
17+
18+
static class ContactMixin implements Contact {
19+
@JsonProperty
20+
public String getCity() { return null; }
21+
}
22+
23+
public interface Person extends Contact {}
24+
25+
static class PersonImpl extends ContactImpl implements Person {}
26+
27+
static class PersonMixin extends ContactMixin implements Person {}
28+
29+
/*
30+
/**********************************************************
31+
/* Unit tests
32+
/**********************************************************
33+
*/
34+
735
// for [Issue#515]
836
public void testDisappearingMixins515() throws Exception
937
{
10-
// TBI
38+
ObjectMapper mapper = new ObjectMapper();
39+
mapper.disable(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS)
40+
.disable(MapperFeature.AUTO_DETECT_FIELDS)
41+
.disable(MapperFeature.AUTO_DETECT_GETTERS)
42+
.disable(MapperFeature.AUTO_DETECT_IS_GETTERS)
43+
.disable(MapperFeature.INFER_PROPERTY_MUTATORS);
44+
SimpleModule module = new SimpleModule("Test");
45+
module.setMixInAnnotation(Person.class, PersonMixin.class);
46+
mapper.registerModule(module);
47+
48+
assertEquals("{\"city\":\"Seattle\"}", mapper.writeValueAsString(new PersonImpl()));
1149
}
1250
}

0 commit comments

Comments
 (0)