Rethrow XMLStreamExceptions as DecodingExceptions

Prior to this commit, Jaxb2XmlDecoder and XmlEventDecoder threw
XMLStreamExceptions instead of DecodingExceptions (as the Decoder
contract defines).

This commit resolves this issue.

Closes: gh-24778
This commit is contained in:
Arjen Poutsma
2020-06-10 15:56:45 +02:00
parent eb3be3ad88
commit 202799e6fe
3 changed files with 13 additions and 8 deletions

View File

@@ -22,7 +22,6 @@ import java.util.List;
import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
import org.junit.jupiter.api.Test;
@@ -32,6 +31,7 @@ import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.DecodingException;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.testfixture.io.buffer.AbstractLeakCheckingTests;
import org.springframework.http.MediaType;
@@ -225,7 +225,7 @@ public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
Mono<Object> result = this.decoder.decodeToMono(source, ResolvableType.forClass(Pojo.class), null, HINTS);
StepVerifier.create(result).verifyErrorSatisfies(ex ->
assertThat(Exceptions.unwrap(ex)).isInstanceOf(XMLStreamException.class));
assertThat(Exceptions.unwrap(ex)).isInstanceOf(DecodingException.class));
}
@Test