From 283b3ee44be2fe89e7a944a10a69a72eb28d1662 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 19 Mar 2013 10:51:30 +0100 Subject: [PATCH] Fixed Jaxb2Marshaller's partial unmarshalling feature to consistently apply to all sources Issue: SPR-10282 --- .../org/springframework/oxm/jaxb/Jaxb2Marshaller.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java index 4ffd0c495d..8df021c7a6 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java @@ -720,7 +720,7 @@ public class Jaxb2Marshaller 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 @@ public class Jaxb2Marshaller 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");