Skip to content

Commit 283b3ee

Browse files
committed
Fixed Jaxb2Marshaller's partial unmarshalling feature to consistently apply to all sources
Issue: SPR-10282
1 parent dc9fee0 commit 283b3ee

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ public Object unmarshal(Source source, MimeContainer mimeContainer) throws XmlMa
720720
return unmarshalStaxSource(unmarshaller, source);
721721
}
722722
else if (this.mappedClass != null) {
723-
return unmarshaller.unmarshal(source, this.mappedClass);
723+
return unmarshaller.unmarshal(source, this.mappedClass).getValue();
724724
}
725725
else {
726726
return unmarshaller.unmarshal(source);
@@ -734,12 +734,16 @@ else if (this.mappedClass != null) {
734734
protected Object unmarshalStaxSource(Unmarshaller jaxbUnmarshaller, Source staxSource) throws JAXBException {
735735
XMLStreamReader streamReader = StaxUtils.getXMLStreamReader(staxSource);
736736
if (streamReader != null) {
737-
return jaxbUnmarshaller.unmarshal(streamReader);
737+
return (this.mappedClass != null ?
738+
jaxbUnmarshaller.unmarshal(streamReader, this.mappedClass).getValue() :
739+
jaxbUnmarshaller.unmarshal(streamReader));
738740
}
739741
else {
740742
XMLEventReader eventReader = StaxUtils.getXMLEventReader(staxSource);
741743
if (eventReader != null) {
742-
return jaxbUnmarshaller.unmarshal(eventReader);
744+
return (this.mappedClass != null ?
745+
jaxbUnmarshaller.unmarshal(eventReader, this.mappedClass).getValue() :
746+
jaxbUnmarshaller.unmarshal(eventReader));
743747
}
744748
else {
745749
throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader");

0 commit comments

Comments
 (0)