Permalink
Browse files

Fixed Jaxb2Marshaller's partial unmarshalling feature to consistently…

… apply to all sources

Issue: SPR-10282
  • Loading branch information...
1 parent dc9fee0 commit 283b3ee44be2fe89e7a944a10a69a72eb28d1662 @jhoeller jhoeller committed Mar 19, 2013
Showing with 7 additions and 3 deletions.
  1. +7 −3 spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java
@@ -720,7 +720,7 @@ public Object unmarshal(Source source, MimeContainer mimeContainer) throws XmlMa
return unmarshalStaxSource(unmarshaller, source);
}
else if (this.mappedClass != null) {
- return unmarshaller.unmarshal(source, this.mappedClass);
+ return unmarshaller.unmarshal(source, this.mappedClass).getValue();
}
else {
return unmarshaller.unmarshal(source);
@@ -734,12 +734,16 @@ else if (this.mappedClass != null) {
protected Object unmarshalStaxSource(Unmarshaller jaxbUnmarshaller, Source staxSource) throws JAXBException {
XMLStreamReader streamReader = StaxUtils.getXMLStreamReader(staxSource);
if (streamReader != null) {
- return jaxbUnmarshaller.unmarshal(streamReader);
+ return (this.mappedClass != null ?
+ jaxbUnmarshaller.unmarshal(streamReader, this.mappedClass).getValue() :
+ jaxbUnmarshaller.unmarshal(streamReader));
}
else {
XMLEventReader eventReader = StaxUtils.getXMLEventReader(staxSource);
if (eventReader != null) {
- return jaxbUnmarshaller.unmarshal(eventReader);
+ return (this.mappedClass != null ?
+ jaxbUnmarshaller.unmarshal(eventReader, this.mappedClass).getValue() :
+ jaxbUnmarshaller.unmarshal(eventReader));
}
else {
throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader");

0 comments on commit 283b3ee

Please sign in to comment.