@@ -121,7 +121,9 @@ public boolean canRead(Class<?> clazz, @Nullable MediaType mediaType) {
121
121
122
122
@ Override
123
123
public boolean canWrite (Class <?> clazz , @ Nullable MediaType mediaType ) {
124
- return ((JAXBElement .class .isAssignableFrom (clazz ) || AnnotationUtils .findAnnotation (clazz , XmlRootElement .class ) != null ) && canWrite (mediaType ));
124
+ boolean supportedType = (JAXBElement .class .isAssignableFrom (clazz ) ||
125
+ AnnotationUtils .findAnnotation (clazz , XmlRootElement .class ) != null );
126
+ return (supportedType && canWrite (mediaType ));
125
127
}
126
128
127
129
@ Override
@@ -190,12 +192,12 @@ protected Source processSource(Source source) {
190
192
}
191
193
192
194
@ Override
193
- protected void writeToResult (Object o , HttpHeaders headers , Result result ) throws Exception {
195
+ protected void writeToResult (Object value , HttpHeaders headers , Result result ) throws Exception {
194
196
try {
195
- Class <?> clazz = getMarshallerType (o );
197
+ Class <?> clazz = getMarshallerType (value );
196
198
Marshaller marshaller = createMarshaller (clazz );
197
199
setCharset (headers .getContentType (), marshaller );
198
- marshaller .marshal (o , result );
200
+ marshaller .marshal (value , result );
199
201
}
200
202
catch (MarshalException ex ) {
201
203
throw ex ;
@@ -205,12 +207,12 @@ protected void writeToResult(Object o, HttpHeaders headers, Result result) throw
205
207
}
206
208
}
207
209
208
- private static Class <?> getMarshallerType (Object o ) {
209
- if (o instanceof JAXBElement <?> jaxbElement ) {
210
+ private static Class <?> getMarshallerType (Object value ) {
211
+ if (value instanceof JAXBElement <?> jaxbElement ) {
210
212
return jaxbElement .getDeclaredType ();
211
213
}
212
214
else {
213
- return ClassUtils .getUserClass (o );
215
+ return ClassUtils .getUserClass (value );
214
216
}
215
217
}
216
218
0 commit comments