Skip to content

Commit 21df384

Browse files
committed
finish override logic and split test logic up
1 parent 3ec2537 commit 21df384

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -952,13 +952,13 @@ private void _addOrOverrideAnnotations(AnnotatedMember target, Annotation[] anns
952952
if (anns != null) {
953953
List<Annotation[]> bundles = null;
954954
for (Annotation ann : anns) { // first: direct annotations
955-
if (_isAnnotationBundle(ann)) {
955+
// note: we will NOT filter out non-Jackson anns any more
956+
boolean wasModified = target.addOrOverride(ann);
957+
if (wasModified && _isAnnotationBundle(ann)) {
956958
if (bundles == null) {
957959
bundles = new LinkedList<Annotation[]>();
958960
}
959961
bundles.add(ann.annotationType().getDeclaredAnnotations());
960-
} else { // note: no filtering by jackson-annotations
961-
target.addOrOverride(ann);
962962
}
963963
}
964964
if (bundles != null) { // and then bundles, if any: important for precedence

src/test/java/com/fasterxml/jackson/databind/introspect/TestAnnotionBundles.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ public class Bean92 {
6767
@Retention(RetentionPolicy.RUNTIME)
6868
static @interface HolderB {}
6969

70-
static class HolderHolder {
71-
@HolderA
72-
@InformativeHolder
73-
public int unimportant = 42;
70+
static class RecursiveHolder {
71+
@HolderA public int unimportant = 42;
7472
}
7573

7674
@JsonProperty
@@ -81,6 +79,10 @@ static class HolderHolder {
8179
boolean important() default true;
8280
}
8381

82+
static class InformingHolder {
83+
@InformativeHolder public int unimportant = 42;
84+
}
85+
8486
static class BundleAnnotationIntrospector extends JacksonAnnotationIntrospector {
8587
@Override
8688
public PropertyName findNameForSerialization(Annotated a)
@@ -104,12 +106,12 @@ public PropertyName findNameForSerialization(Annotated a)
104106
public void testKeepAnnotationBundle() throws Exception
105107
{
106108
MAPPER.setAnnotationIntrospector(new BundleAnnotationIntrospector());
107-
assertEquals("{\"important\":42}", MAPPER.writeValueAsString(new HolderHolder()));
109+
assertEquals("{\"important\":42}", MAPPER.writeValueAsString(new InformingHolder()));
108110
}
109111

110112
public void testRecursiveBundles() throws Exception
111113
{
112-
assertEquals("{\"unimportant\":42}", MAPPER.writeValueAsString(new HolderHolder()));
114+
assertEquals("{\"unimportant\":42}", MAPPER.writeValueAsString(new RecursiveHolder()));
113115
}
114116

115117
public void testBundledIgnore() throws Exception

0 commit comments

Comments
 (0)