From db612bb3839581d0a88297667880cad548c018b1 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 26 Apr 2015 22:42:17 -0700 Subject: [PATCH] Fix #771 --- release-notes/CREDITS | 5 +++++ release-notes/VERSION | 2 ++ .../jackson/databind/introspect/AnnotatedClass.java | 4 ++-- .../fasterxml/jackson/databind/introspect/AnnotationMap.java | 5 ++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/release-notes/CREDITS b/release-notes/CREDITS index 764cca3f0b..ce0cae00d3 100644 --- a/release-notes/CREDITS +++ b/release-notes/CREDITS @@ -240,3 +240,8 @@ John Meyer (jpmeyer@github) * Reported, contributed fix for #745: EnumDeserializer.deserializerForCreator() fails when used to deserialize a Map key (2.5.3) + +Andrew Duckett (andrewduckett@github) + * Reported #771: Annotation bundles ignored when added to Mixin + (2.5.4) + diff --git a/release-notes/VERSION b/release-notes/VERSION index 22b14ff6cd..eed8c9895b 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -6,6 +6,8 @@ Project: jackson-databind 2.5.4 (not yet released) +#771: Annotation bundles ignored when added to Mixin + (reported by Andrew D) - Fix handling of Enums wrt JSON Schema, when 'toString()' used for serialization 2.5.3 (24-Apr-2015) diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedClass.java b/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedClass.java index 2224bae565..0473a11352 100644 --- a/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedClass.java +++ b/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedClass.java @@ -424,7 +424,7 @@ private void resolveMemberMethods() AnnotatedMethodMap mixins = new AnnotatedMethodMap(); // first: methods from the class itself _addMemberMethods(_class, _memberMethods, _primaryMixIn, mixins); - + // and then augment these with annotations from super-types: for (Class cls : _superTypes) { Class mixin = (_mixInResolver == null) ? null : _mixInResolver.findMixInClassFor(cls); @@ -594,7 +594,7 @@ protected void _addMemberMethods(Class cls, AnnotatedMethodMap methods, // first, mixIns, since they have higher priority then class methods if (mixInCls != null) { _addMethodMixIns(cls, methods, mixInCls, mixIns); - } + } if (cls == null) { // just so caller need not check when passing super-class return; } diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotationMap.java b/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotationMap.java index 0b514ffb51..513a83d909 100644 --- a/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotationMap.java +++ b/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotationMap.java @@ -82,6 +82,9 @@ public boolean addIfNotPresent(Annotation ann) /** * Method called to add specified annotation in the Map. + * + * @return True if the addition changed the contents, that is, this map did not + * already have specified annotation */ public boolean add(Annotation ann) { return _add(ann); @@ -106,7 +109,7 @@ protected final boolean _add(Annotation ann) { _annotations = new HashMap,Annotation>(); } Annotation previous = _annotations.put(ann.annotationType(), ann); - return (previous != null) && previous.equals(ann); + return (previous == null) || !previous.equals(ann); } }