Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XStreamMarshaller should convert XStream StreamException to Spring exception in case of unmarshalling an empty stream [SPR-9536] #14170

spring-projects-issues opened this issue Jun 23, 2012 · 1 comment


Copy link

@spring-projects-issues spring-projects-issues commented Jun 23, 2012

Neil Brown opened SPR-9536 and commented

The constructor for an XStream XppReader can throw an XStream StreamException, e.g. in the case where it is constructed from an empty stream. (This can occur if an attempt is made to unmarshall an empty HTTP request). For consistency, the Spring XStreamMarshaller should catch this occurrence of a StreamException, and convert (wrap and rethrow) it to a Spring UnmarshallingFailureException as it does in other cases.

TestCase follows -



import org.junit.Before;
import org.junit.Test;
import org.springframework.oxm.UnmarshallingFailureException;
import org.springframework.oxm.xstream.XStreamMarshaller;


 * Unit tests for {@link XStreamMarshaller}.
public class XStreamMarshallerTest {
  private XStreamMarshaller uut;

   * Set-up test fixtures.
  public void setUp() {
    this.uut = new XStreamMarshaller();

   * Tests {@link org.springframework.oxm.xstream.XStreamMarshaller#unmarshalReader(} in the case
   * where the input stream is empty, and the marshaller is not configured to use a supplied stream driver, and so 
   * creates a new instance of {@link XppReader}.
   * <p>
   * In this scenario {@link XppReader#XppReader(,} 
   * throws a {@link StreamException} when {@link XppReader#moveDown()} is invoked on the empty stream. The 
   * {@link XStreamMarshaller} should convert the {@link StreamException} to a generic Spring 
   * {@link UnmarshallingFailureException}.
   * @throws Exception If an unexpected error occurs on execution of this test.
  public final void testUnmarshalReader() throws Exception {
    this.uut.unmarshal(new StreamSource(new StringReader("")));

Affects: 3.1.1


  • #14174 Backport XStreamMarshaller should convert XStream StreamException to Spring exception in case of unmarshalling an empty stream
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jun 28, 2012

Juergen Hoeller commented

Arjen, I've slightly refined your original fix so that our IllegalArgumentException doesn't get wrapped in unmarshalDomNode. The actual culprit of this issue seems to be in unmarshalReader anyway.



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants