diff --git a/release-notes/VERSION b/release-notes/VERSION index ba6892e..a21c859 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -4,6 +4,11 @@ Project: jackson-module-jaxb-annotations === Releases === ------------------------------------------------------------------------ +2.6.2 (not yet released) + +#47: JaxbAnnotationIntrospector does not pick up 'required' property of @XmlAttribute + (reported by phantomjinx@github) + 2.6.1 (09-Aug-2015) 2.6.0 (19-Jul-2015) diff --git a/src/main/java/com/fasterxml/jackson/module/jaxb/JaxbAnnotationIntrospector.java b/src/main/java/com/fasterxml/jackson/module/jaxb/JaxbAnnotationIntrospector.java index 802d49d..4adc82c 100644 --- a/src/main/java/com/fasterxml/jackson/module/jaxb/JaxbAnnotationIntrospector.java +++ b/src/main/java/com/fasterxml/jackson/module/jaxb/JaxbAnnotationIntrospector.java @@ -1042,8 +1042,21 @@ public boolean hasCreatorAnnotation(Annotated am) { @Override public Boolean hasRequiredMarker(AnnotatedMember m) { - XmlElement annotation = m.getAnnotation(XmlElement.class); - return annotation == null ? null : Boolean.valueOf(annotation.required()); + XmlElement elem = m.getAnnotation(XmlElement.class); + if ((elem != null) && elem.required()) { + return Boolean.TRUE; + } + XmlAttribute attr = m.getAnnotation(XmlAttribute.class); + if ((attr != null) && attr.required()) { + return Boolean.TRUE; + } + // 09-Sep-2015, tatu: Not 100% sure that we should ever return `false` + // here (as it blocks calls to secondary introspector), but since that + // was the existing behavior before 2.6, is retained for now. + if ((elem != null) || (attr != null)) { + return null; + } + return Boolean.FALSE; } @Override