Skip to content

Commit fbef49b

Browse files
committed
Fix #32 as per suggestion
1 parent 4f1acfd commit fbef49b

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

jaxb/src/main/java/com/fasterxml/jackson/module/jaxb/JaxbAnnotationIntrospector.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -433,21 +433,19 @@ public boolean hasAnySetterAnnotation(AnnotatedMethod am)
433433

434434
@Override
435435
public Boolean hasRequiredMarker(AnnotatedMember m) {
436-
XmlElement elem = m.getAnnotation(XmlElement.class);
437-
if ((elem != null) && elem.required()) {
438-
return Boolean.TRUE;
439-
}
436+
// 17-Oct-2017, tatu: [modules-base#32]
437+
// Before 2.9.3, was handling `true` correctly,
438+
// but otherwise used confusing logic (probably in attempt to try to avoid
439+
// reporting not-required for default value case
440440
XmlAttribute attr = m.getAnnotation(XmlAttribute.class);
441-
if ((attr != null) && attr.required()) {
442-
return Boolean.TRUE;
441+
if (attr != null) {
442+
return attr.required();
443443
}
444-
// 09-Sep-2015, tatu: Not 100% sure that we should ever return `false`
445-
// here (as it blocks calls to secondary introspector), but since that
446-
// was the existing behavior before 2.6, is retained for now.
447-
if ((elem != null) || (attr != null)) {
448-
return null;
444+
XmlElement elem = m.getAnnotation(XmlElement.class);
445+
if (elem != null) {
446+
return elem.required();
449447
}
450-
return Boolean.FALSE;
448+
return null;
451449
}
452450

453451
@Override

release-notes/CREDITS

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Here are people who have contributed to development Jackson JSON processor
2+
Base modules
3+
(version numbers in brackets indicate release in which the problem was fixed)
4+
(NOTE: incomplete -- need to collect info from sub-projects, pre-2.9)
5+
6+
Tatu Saloranta, [email protected]: author
7+
8+
Vojtěch Habarta (vojtechhabarta@gitub)
9+
10+
* Reported [JAXB#32]: Fix introspector chaining in `JaxbAnnotationIntrospector.hasRequiredMarker()`
11+
(2.9.3)

release-notes/VERSION

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ Modules:
88
=== Releases ===
99
------------------------------------------------------------------------
1010

11+
2.9.3 (not yet released)
12+
13+
#32: Fix introspector chaining in `JaxbAnnotationIntrospector.hasRequiredMarker()`
14+
(reported by Vojtěch H)
15+
1116
2.9.2 (14-Oct-2017)
1217

1318
#30: (afterburner) `IncompatibleClassChangeError` deserializing interface

0 commit comments

Comments
 (0)