mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-02 15:29:05 +00:00
Corrected ProblemDetail mixin for XmlMapper.Builder
The ProblemDetailXmlMapperBuilderCustomizer applied the wrong ProblemDetail mixin for the Jackson XmlMapper. Namely the ProblemDetailJacksonMixin, which is intended for JSON. Now the ProblemDetailJacksonXmlMixin is used instead. The corresponding test also tested for the wrong XML output, which has been adjusted. Fixes gh-48222 Signed-off-by: Maurice Zeijen <mzeijen@bol.com>
This commit is contained in:
committed by
Brian Clozel
parent
0a4037880c
commit
a39adff3eb
+2
-1
@@ -66,6 +66,7 @@ import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.http.ProblemDetail;
|
||||
import org.springframework.http.converter.json.ProblemDetailJacksonMixin;
|
||||
import org.springframework.http.converter.json.ProblemDetailJacksonXmlMixin;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -282,7 +283,7 @@ public final class JacksonAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public void customize(XmlMapper.Builder builder) {
|
||||
builder.addMixIn(ProblemDetail.class, ProblemDetailJacksonMixin.class);
|
||||
builder.addMixIn(ProblemDetail.class, ProblemDetailJacksonXmlMixin.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -691,7 +691,7 @@ class JacksonAutoConfigurationTests {
|
||||
problemDetail.setProperty("spring", "boot");
|
||||
String xml = mapper.writeValueAsString(problemDetail);
|
||||
assertThat(xml).isEqualTo(
|
||||
"<ProblemDetail><status>404</status><title>Not Found</title><spring>boot</spring></ProblemDetail>");
|
||||
"<problem xmlns=\"urn:ietf:rfc:7807\"><status>404</status><title>Not Found</title><spring>boot</spring></problem>");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user